Maverik Modeling Assignment

Team Name: Here for the Cinnabon

Roman Brock

Bhoomika John Pedely

Biva Sherchan

Pablo Zarate

Introduction

Maverik needs an accurate daily forecast of sales metrics for a new store's first year of sales. Achieving this allows for more effective financial planning and accurate ROI documents.

This is a supervised regression problem where the predictors involve both categorical and numerical variables and the targets are four sales metrics.

This modeling assignment will show four different models used to forecast sales for a new store. We are using ETS, ARIMA, Prophet and XGBoost to forecast sales and will compare results.

Data Preparation

We have two dataframes that we are combining based on the ID of the store.

Columns with null vaules were replaced with 'None'.

Store 21980 has exceptionally high diesel sales. As this is an outlier in our sales trend, we will remove this from the dataframes.

For the Prophet model, we are using one-hot encoding for some variables so that they help in building a better predictive model.

In [ ]:
import warnings
warnings.filterwarnings('ignore')
In [ ]:
#Installing Dependencies
import pandas as pd
import numpy as np
import datetime
import matplotlib.pyplot as plt
import seaborn as sns

from sklearn.preprocessing import LabelEncoder
from statsmodels.tsa.holtwinters import ExponentialSmoothing
from sklearn.metrics import mean_absolute_error, mean_squared_error
In [ ]:
#Loading data
# File paths
time_series = "/Users/pablozarate/Documents/MSBA/Maverick/time_series_data_msba.csv"
qual_data = '/Users/pablozarate/Documents/MSBA/Maverick/qualitative_data_msba.csv'
data_sales = pd.read_csv(time_series)
data_stores = pd.read_csv(qual_data)
In [ ]:
#Merging the datasets
df = data_stores.merge(data_sales, how = 'inner', on=['site_id_msba'])
# pd.set_option('display.max_columns', None)
# df.head()
Out[ ]:
Unnamed: 0_x open_year square_feet front_door_count years_since_last_project parking_spaces lottery freal bonfire_grill pizza cinnabon godfather_s_pizza ethanol_free diesel_x hi_flow_lanes rv_lanes hi_flow_rv_lanes def cat_scales car_wash ev_charging rv_dumps propane x1_mile_pop x1_mile_emp x1_mile_income x1_2_mile_pop x1_2_mile_emp x1_2_mile_income x5_min_pop x5_min_emp x5_min_inc x7_min_pop x7_min_emp x7_min_inc traditional_forecourt_fueling_positions traditional_forecourt_layout traditional_forecourt_stack_type rv_lanes_fueling_positions rv_lanes_layout rv_lanes_stack_type hi_flow_lanes_fueling_positions hi_flow_lanes_layout hi_flow_lanes_stack_type hi_flow_lanes_fueling_positions_2 rv_lanes_fueling_positions_2 hi_flow_rv_lanes_layout hi_flow_rv_lanes_stack_type non_24_hour self_check_out mens_toilet_count mens_urinal_count womens_toilet_count womens_sink_count site_id_msba Unnamed: 0_y capital_projects.soft_opening_date calendar.calendar_day_date calendar.fiscal_week_id_for_year calendar.day_of_week calendar_information.holiday calendar_information.type_of_day daily_yoy_ndt.total_inside_sales daily_yoy_ndt.total_food_service diesel_y unleaded
0 1 2021 5046 2 2 38 Yes Yes Yes No No No Yes Yes Yes Yes Yes Yes No No No Yes Yes 4046 3648 43435 556 642 45678 4776 5364 41725 13895 7906 46043 20 Stack Large 6 Stack HF/RV 4 Stack HF/RV 4 6 Stack HF/RV No Yes 2 2 6 2 21560 13543 2021-01-12 2021-01-17 3 Sunday NONE WEEKEND 1792.1260 528.8185 870.0160 1490.3980
1 1 2021 5046 2 2 38 Yes Yes Yes No No No Yes Yes Yes Yes Yes Yes No No No Yes Yes 4046 3648 43435 556 642 45678 4776 5364 41725 13895 7906 46043 20 Stack Large 6 Stack HF/RV 4 Stack HF/RV 4 6 Stack HF/RV No Yes 2 2 6 2 21560 13544 2021-01-12 2021-01-20 3 Wednesday NONE WEEKDAY 2297.4595 793.7300 1582.0420 1750.7525
2 1 2021 5046 2 2 38 Yes Yes Yes No No No Yes Yes Yes Yes Yes Yes No No No Yes Yes 4046 3648 43435 556 642 45678 4776 5364 41725 13895 7906 46043 20 Stack Large 6 Stack HF/RV 4 Stack HF/RV 4 6 Stack HF/RV No Yes 2 2 6 2 21560 13545 2021-01-12 2021-01-21 3 Thursday NONE WEEKDAY 2381.5120 829.0730 1506.6660 1727.6210
3 1 2021 5046 2 2 38 Yes Yes Yes No No No Yes Yes Yes Yes Yes Yes No No No Yes Yes 4046 3648 43435 556 642 45678 4776 5364 41725 13895 7906 46043 20 Stack Large 6 Stack HF/RV 4 Stack HF/RV 4 6 Stack HF/RV No Yes 2 2 6 2 21560 13546 2021-01-12 2021-01-24 4 Sunday NONE WEEKEND 1396.4370 456.1830 510.9370 1184.8060
4 1 2021 5046 2 2 38 Yes Yes Yes No No No Yes Yes Yes Yes Yes Yes No No No Yes Yes 4046 3648 43435 556 642 45678 4776 5364 41725 13895 7906 46043 20 Stack Large 6 Stack HF/RV 4 Stack HF/RV 4 6 Stack HF/RV No Yes 2 2 6 2 21560 13547 2021-01-12 2021-01-29 5 Friday NONE WEEKDAY 2568.2370 782.6245 1604.0325 1987.2720
In [ ]:
#Checking for null
df.info()

#There are 6 columns with null values. These null values mean that the feature is not available. Replacing them with 'None'
<class 'pandas.core.frame.DataFrame'>
Int64Index: 13542 entries, 0 to 13541
Data columns (total 66 columns):
 #   Column                                   Non-Null Count  Dtype  
---  ------                                   --------------  -----  
 0   Unnamed: 0_x                             13542 non-null  int64  
 1   open_year                                13542 non-null  int64  
 2   square_feet                              13542 non-null  int64  
 3   front_door_count                         13542 non-null  int64  
 4   years_since_last_project                 13542 non-null  int64  
 5   parking_spaces                           13542 non-null  int64  
 6   lottery                                  13542 non-null  object 
 7   freal                                    13542 non-null  object 
 8   bonfire_grill                            13542 non-null  object 
 9   pizza                                    13542 non-null  object 
 10  cinnabon                                 13542 non-null  object 
 11  godfather_s_pizza                        13542 non-null  object 
 12  ethanol_free                             13542 non-null  object 
 13  diesel_x                                 13542 non-null  object 
 14  hi_flow_lanes                            13542 non-null  object 
 15  rv_lanes                                 13542 non-null  object 
 16  hi_flow_rv_lanes                         13542 non-null  object 
 17  def                                      13542 non-null  object 
 18  cat_scales                               13542 non-null  object 
 19  car_wash                                 13542 non-null  object 
 20  ev_charging                              13542 non-null  object 
 21  rv_dumps                                 13542 non-null  object 
 22  propane                                  13542 non-null  object 
 23  x1_mile_pop                              13542 non-null  int64  
 24  x1_mile_emp                              13542 non-null  int64  
 25  x1_mile_income                           13542 non-null  int64  
 26  x1_2_mile_pop                            13542 non-null  int64  
 27  x1_2_mile_emp                            13542 non-null  int64  
 28  x1_2_mile_income                         13542 non-null  int64  
 29  x5_min_pop                               13542 non-null  int64  
 30  x5_min_emp                               13542 non-null  int64  
 31  x5_min_inc                               13542 non-null  int64  
 32  x7_min_pop                               13542 non-null  int64  
 33  x7_min_emp                               13542 non-null  int64  
 34  x7_min_inc                               13542 non-null  int64  
 35  traditional_forecourt_fueling_positions  13542 non-null  int64  
 36  traditional_forecourt_layout             13542 non-null  object 
 37  traditional_forecourt_stack_type         13542 non-null  object 
 38  rv_lanes_fueling_positions               13542 non-null  int64  
 39  rv_lanes_layout                          8418 non-null   object 
 40  rv_lanes_stack_type                      8418 non-null   object 
 41  hi_flow_lanes_fueling_positions          13542 non-null  int64  
 42  hi_flow_lanes_layout                     8052 non-null   object 
 43  hi_flow_lanes_stack_type                 8052 non-null   object 
 44  hi_flow_lanes_fueling_positions_2        13542 non-null  int64  
 45  rv_lanes_fueling_positions_2             13542 non-null  int64  
 46  hi_flow_rv_lanes_layout                  8418 non-null   object 
 47  hi_flow_rv_lanes_stack_type              8418 non-null   object 
 48  non_24_hour                              13542 non-null  object 
 49  self_check_out                           13542 non-null  object 
 50  mens_toilet_count                        13542 non-null  int64  
 51  mens_urinal_count                        13542 non-null  int64  
 52  womens_toilet_count                      13542 non-null  int64  
 53  womens_sink_count                        13542 non-null  int64  
 54  site_id_msba                             13542 non-null  int64  
 55  Unnamed: 0_y                             13542 non-null  int64  
 56  capital_projects.soft_opening_date       13542 non-null  object 
 57  calendar.calendar_day_date               13542 non-null  object 
 58  calendar.fiscal_week_id_for_year         13542 non-null  int64  
 59  calendar.day_of_week                     13542 non-null  object 
 60  calendar_information.holiday             13542 non-null  object 
 61  calendar_information.type_of_day         13542 non-null  object 
 62  daily_yoy_ndt.total_inside_sales         13542 non-null  float64
 63  daily_yoy_ndt.total_food_service         13542 non-null  float64
 64  diesel_y                                 13542 non-null  float64
 65  unleaded                                 13542 non-null  float64
dtypes: float64(4), int64(30), object(32)
memory usage: 6.9+ MB
In [ ]:
#Replacing nulls with None
cols_to_fill = ['rv_lanes_layout','rv_lanes_stack_type','hi_flow_lanes_layout','hi_flow_lanes_stack_type','hi_flow_rv_lanes_layout','hi_flow_rv_lanes_stack_type']
for col_name in cols_to_fill:
    df[col_name].fillna("None", inplace=True)
In [ ]:
#Dropping irrelevant columns
df = df.drop(['Unnamed: 0_x','Unnamed: 0_y'], axis = 1)
In [ ]:
#Converting date to datetime
df['calendar.calendar_day_date'] = pd.to_datetime(df['calendar.calendar_day_date'])
df.set_index('calendar.calendar_day_date', inplace=True)
In [ ]:
#Removing data for site id 21980, has exceptionally high diesel sales
df = df[df['site_id_msba'] != 21980]
In [ ]:
df.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 13176 entries, 0 to 13541
Data columns (total 64 columns):
 #   Column                                   Non-Null Count  Dtype         
---  ------                                   --------------  -----         
 0   open_year                                13176 non-null  int64         
 1   square_feet                              13176 non-null  int64         
 2   front_door_count                         13176 non-null  int64         
 3   years_since_last_project                 13176 non-null  int64         
 4   parking_spaces                           13176 non-null  int64         
 5   lottery                                  13176 non-null  object        
 6   freal                                    13176 non-null  object        
 7   bonfire_grill                            13176 non-null  object        
 8   pizza                                    13176 non-null  object        
 9   cinnabon                                 13176 non-null  object        
 10  godfather_s_pizza                        13176 non-null  object        
 11  ethanol_free                             13176 non-null  object        
 12  diesel_x                                 13176 non-null  object        
 13  hi_flow_lanes                            13176 non-null  object        
 14  rv_lanes                                 13176 non-null  object        
 15  hi_flow_rv_lanes                         13176 non-null  object        
 16  def                                      13176 non-null  object        
 17  cat_scales                               13176 non-null  object        
 18  car_wash                                 13176 non-null  object        
 19  ev_charging                              13176 non-null  object        
 20  rv_dumps                                 13176 non-null  object        
 21  propane                                  13176 non-null  object        
 22  x1_mile_pop                              13176 non-null  int64         
 23  x1_mile_emp                              13176 non-null  int64         
 24  x1_mile_income                           13176 non-null  int64         
 25  x1_2_mile_pop                            13176 non-null  int64         
 26  x1_2_mile_emp                            13176 non-null  int64         
 27  x1_2_mile_income                         13176 non-null  int64         
 28  x5_min_pop                               13176 non-null  int64         
 29  x5_min_emp                               13176 non-null  int64         
 30  x5_min_inc                               13176 non-null  int64         
 31  x7_min_pop                               13176 non-null  int64         
 32  x7_min_emp                               13176 non-null  int64         
 33  x7_min_inc                               13176 non-null  int64         
 34  traditional_forecourt_fueling_positions  13176 non-null  int64         
 35  traditional_forecourt_layout             13176 non-null  object        
 36  traditional_forecourt_stack_type         13176 non-null  object        
 37  rv_lanes_fueling_positions               13176 non-null  int64         
 38  rv_lanes_layout                          8052 non-null   object        
 39  rv_lanes_stack_type                      8052 non-null   object        
 40  hi_flow_lanes_fueling_positions          13176 non-null  int64         
 41  hi_flow_lanes_layout                     7686 non-null   object        
 42  hi_flow_lanes_stack_type                 7686 non-null   object        
 43  hi_flow_lanes_fueling_positions_2        13176 non-null  int64         
 44  rv_lanes_fueling_positions_2             13176 non-null  int64         
 45  hi_flow_rv_lanes_layout                  8052 non-null   object        
 46  hi_flow_rv_lanes_stack_type              8052 non-null   object        
 47  non_24_hour                              13176 non-null  object        
 48  self_check_out                           13176 non-null  object        
 49  mens_toilet_count                        13176 non-null  int64         
 50  mens_urinal_count                        13176 non-null  int64         
 51  womens_toilet_count                      13176 non-null  int64         
 52  womens_sink_count                        13176 non-null  int64         
 53  site_id_msba                             13176 non-null  int64         
 54  capital_projects.soft_opening_date       13176 non-null  object        
 55  calendar.calendar_day_date               13176 non-null  datetime64[ns]
 56  calendar.fiscal_week_id_for_year         13176 non-null  int64         
 57  calendar.day_of_week                     13176 non-null  object        
 58  calendar_information.holiday             13176 non-null  object        
 59  calendar_information.type_of_day         13176 non-null  object        
 60  daily_yoy_ndt.total_inside_sales         13176 non-null  float64       
 61  daily_yoy_ndt.total_food_service         13176 non-null  float64       
 62  diesel_y                                 13176 non-null  float64       
 63  unleaded                                 13176 non-null  float64       
dtypes: datetime64[ns](1), float64(4), int64(28), object(31)
memory usage: 6.5+ MB
In [ ]:
# Making copy of DF for Prophet
df_prophet_copy = df.copy()
# One-Hot Encoding for Prophet
categorical_columns = ['pizza','rv_lanes','def','rv_lanes_layout','hi_flow_lanes','hi_flow_rv_lanes']

for column in categorical_columns:
    # Get the one-hot encoded dataframe for the current column
    one_hot = pd.get_dummies(df_prophet_copy[column], prefix=column)
    # Drop the original categorical column from the dataframe
    df_prophet_copy = df_prophet_copy.drop(column, axis=1)
    # Join the one-hot encoded dataframe back with the original dataframe
    df_prophet_copy = df_prophet_copy.join(one_hot)
In [ ]:
# Renaming msba site id to store id for Prophet
df_prophet_copy.rename(columns={'site_id_msba': 'store_id'}, inplace=True)

# Segmenting dataframes by sales metric for Prophet
prophet_df_unleaded = df_prophet_copy[['store_id', 'calendar.calendar_day_date', 'unleaded', 'calendar_information.holiday'
                        ,'x1_mile_pop', 'x1_mile_emp', 'x1_mile_income', 'x1_2_mile_pop', 'x1_2_mile_emp', 'x1_2_mile_income', 'x5_min_pop', 'x5_min_emp','x5_min_inc'
                        ,'x7_min_pop', 'x7_min_emp', 'x7_min_inc', 'open_year', 'hi_flow_lanes_fueling_positions', 'mens_urinal_count', 'mens_toilet_count'
                        , 'womens_sink_count'
                        ,'pizza_No', 'pizza_Yes', 'rv_lanes_No', 'rv_lanes_Yes', 'def_No', 'def_Yes', 'rv_lanes_layout_In-Line', 'rv_lanes_layout_None'
                        , 'rv_lanes_layout_Stack', 'hi_flow_lanes_No', 'hi_flow_lanes_Yes', 'hi_flow_rv_lanes_No', 'hi_flow_rv_lanes_Yes'
                        ]].copy()
prophet_df_unleaded.rename(columns={'calendar.calendar_day_date': 'ds', 'unleaded': 'y'}, inplace=True)

prophet_df_diesel = df_prophet_copy[['store_id', 'calendar.calendar_day_date', 'diesel_y', 'calendar_information.holiday'
                        ,'x1_mile_pop', 'x1_mile_emp', 'x1_mile_income', 'x1_2_mile_pop', 'x1_2_mile_emp', 'x1_2_mile_income', 'x5_min_pop', 'x5_min_emp','x5_min_inc'
                        ,'x7_min_pop', 'x7_min_emp', 'x7_min_inc', 'open_year', 'hi_flow_lanes_fueling_positions', 'mens_urinal_count', 'mens_toilet_count'
                        , 'womens_sink_count'
                        ,'pizza_No', 'pizza_Yes', 'rv_lanes_No', 'rv_lanes_Yes', 'def_No', 'def_Yes', 'rv_lanes_layout_In-Line', 'rv_lanes_layout_None'
                        , 'rv_lanes_layout_Stack', 'hi_flow_lanes_No', 'hi_flow_lanes_Yes', 'hi_flow_rv_lanes_No', 'hi_flow_rv_lanes_Yes'
                        ]].copy()
prophet_df_diesel.rename(columns={'calendar.calendar_day_date': 'ds', 'diesel_y': 'y'}, inplace=True)

prophet_df_food_sales = df_prophet_copy[['store_id', 'calendar.calendar_day_date', 'daily_yoy_ndt.total_food_service', 'calendar_information.holiday'
                        ,'x1_mile_pop', 'x1_mile_emp', 'x1_mile_income', 'x1_2_mile_pop', 'x1_2_mile_emp', 'x1_2_mile_income', 'x5_min_pop', 'x5_min_emp','x5_min_inc'
                        ,'x7_min_pop', 'x7_min_emp', 'x7_min_inc', 'open_year', 'hi_flow_lanes_fueling_positions', 'mens_urinal_count', 'mens_toilet_count'
                        , 'womens_sink_count'
                        ,'pizza_No', 'pizza_Yes', 'rv_lanes_No', 'rv_lanes_Yes', 'def_No', 'def_Yes', 'rv_lanes_layout_In-Line', 'rv_lanes_layout_None'
                        , 'rv_lanes_layout_Stack', 'hi_flow_lanes_No', 'hi_flow_lanes_Yes', 'hi_flow_rv_lanes_No', 'hi_flow_rv_lanes_Yes'
                        ]].copy()
prophet_df_food_sales.rename(columns={'calendar.calendar_day_date': 'ds', 'daily_yoy_ndt.total_food_service': 'y'}, inplace=True)

prophet_df_inside_sales = df_prophet_copy[['store_id', 'calendar.calendar_day_date', 'daily_yoy_ndt.total_inside_sales', 'calendar_information.holiday'
                        ,'x1_mile_pop', 'x1_mile_emp', 'x1_mile_income', 'x1_2_mile_pop', 'x1_2_mile_emp', 'x1_2_mile_income', 'x5_min_pop', 'x5_min_emp','x5_min_inc'
                        ,'x7_min_pop', 'x7_min_emp', 'x7_min_inc', 'open_year', 'hi_flow_lanes_fueling_positions', 'mens_urinal_count', 'mens_toilet_count'
                        , 'womens_sink_count'
                        ,'pizza_No', 'pizza_Yes', 'rv_lanes_No', 'rv_lanes_Yes', 'def_No', 'def_Yes', 'rv_lanes_layout_In-Line', 'rv_lanes_layout_None'
                        , 'rv_lanes_layout_Stack', 'hi_flow_lanes_No', 'hi_flow_lanes_Yes', 'hi_flow_rv_lanes_No', 'hi_flow_rv_lanes_Yes'
                        ]].copy()
prophet_df_inside_sales.rename(columns={'calendar.calendar_day_date': 'ds', 'daily_yoy_ndt.total_inside_sales': 'y'}, inplace=True)

# Now creating a DataFrame for holidays for Prophet
holidays_df = df_prophet_copy[df_prophet_copy['calendar_information.holiday'].notnull()][['calendar.calendar_day_date', 'calendar_information.holiday']].copy()
holidays_df.rename(columns={'calendar.calendar_day_date': 'ds', 'calendar_information.holiday': 'holiday'}, inplace=True)
holidays_df = holidays_df.drop_duplicates()  # Ensure there are no duplicate holiday entries
In [ ]:
categorical_features = []

for column in df.columns:
    if df[column].dtype == 'object':
        categorical_features.append(column)
In [ ]:
#Encoding Categorical Variables
df = pd.get_dummies(df, columns=categorical_features)
In [ ]:
#Converting site_id to categorical
df['site_id_msba'] = df['site_id_msba'].astype('object')
In [ ]:
#Confirming updates
df.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 13176 entries, 0 to 13541
Columns: 152 entries, open_year to calendar_information.type_of_day_WEEKEND
dtypes: datetime64[ns](1), float64(4), int64(27), object(1), uint8(119)
memory usage: 4.9+ MB
In [ ]:
df.head()
Out[ ]:
open_year square_feet front_door_count years_since_last_project parking_spaces x1_mile_pop x1_mile_emp x1_mile_income x1_2_mile_pop x1_2_mile_emp x1_2_mile_income x5_min_pop x5_min_emp x5_min_inc x7_min_pop x7_min_emp x7_min_inc traditional_forecourt_fueling_positions rv_lanes_fueling_positions hi_flow_lanes_fueling_positions hi_flow_lanes_fueling_positions_2 rv_lanes_fueling_positions_2 mens_toilet_count mens_urinal_count womens_toilet_count womens_sink_count site_id_msba calendar.calendar_day_date calendar.fiscal_week_id_for_year daily_yoy_ndt.total_inside_sales daily_yoy_ndt.total_food_service diesel_y unleaded lottery_No lottery_Yes freal_No freal_Yes bonfire_grill_No bonfire_grill_Yes pizza_No pizza_Yes cinnabon_No cinnabon_Yes godfather_s_pizza_No ethanol_free_No ethanol_free_Yes diesel_x_Yes hi_flow_lanes_No hi_flow_lanes_Yes rv_lanes_No rv_lanes_Yes hi_flow_rv_lanes_No hi_flow_rv_lanes_Yes def_No def_Yes cat_scales_No cat_scales_Yes car_wash_No ev_charging_No rv_dumps_No rv_dumps_Yes propane_No propane_Yes traditional_forecourt_layout_In-Line traditional_forecourt_layout_Stack traditional_forecourt_stack_type_Extra-Large traditional_forecourt_stack_type_Large traditional_forecourt_stack_type_None rv_lanes_layout_In-Line rv_lanes_layout_None rv_lanes_layout_Stack rv_lanes_stack_type_HF/RV rv_lanes_stack_type_None hi_flow_lanes_layout_Combo hi_flow_lanes_layout_None hi_flow_lanes_layout_Stack hi_flow_lanes_stack_type_HF/RV hi_flow_lanes_stack_type_None hi_flow_rv_lanes_layout_Combo hi_flow_rv_lanes_layout_In-Line hi_flow_rv_lanes_layout_None hi_flow_rv_lanes_layout_Stack hi_flow_rv_lanes_stack_type_HF/RV hi_flow_rv_lanes_stack_type_None non_24_hour_No self_check_out_Yes capital_projects.soft_opening_date_2021-01-12 capital_projects.soft_opening_date_2021-01-26 capital_projects.soft_opening_date_2021-02-02 capital_projects.soft_opening_date_2021-03-30 capital_projects.soft_opening_date_2021-04-13 capital_projects.soft_opening_date_2021-05-13 capital_projects.soft_opening_date_2021-05-18 capital_projects.soft_opening_date_2021-05-25 capital_projects.soft_opening_date_2021-06-15 capital_projects.soft_opening_date_2021-06-22 capital_projects.soft_opening_date_2021-07-13 capital_projects.soft_opening_date_2021-07-20 capital_projects.soft_opening_date_2021-07-27 capital_projects.soft_opening_date_2021-08-17 capital_projects.soft_opening_date_2021-09-21 capital_projects.soft_opening_date_2021-09-28 capital_projects.soft_opening_date_2021-10-19 capital_projects.soft_opening_date_2021-11-09 capital_projects.soft_opening_date_2021-11-17 capital_projects.soft_opening_date_2021-12-07 capital_projects.soft_opening_date_2022-03-01 capital_projects.soft_opening_date_2022-03-15 capital_projects.soft_opening_date_2022-05-03 capital_projects.soft_opening_date_2022-05-10 capital_projects.soft_opening_date_2022-05-17 capital_projects.soft_opening_date_2022-06-14 capital_projects.soft_opening_date_2022-06-28 capital_projects.soft_opening_date_2022-07-12 capital_projects.soft_opening_date_2022-08-02 capital_projects.soft_opening_date_2022-08-09 capital_projects.soft_opening_date_2022-08-16 calendar.day_of_week_Friday calendar.day_of_week_Monday calendar.day_of_week_Saturday calendar.day_of_week_Sunday calendar.day_of_week_Thursday calendar.day_of_week_Tuesday calendar.day_of_week_Wednesday calendar_information.holiday_All Saint's Day calendar_information.holiday_Ascension calendar_information.holiday_Christmas Day calendar_information.holiday_Christmas Eve calendar_information.holiday_Columbus Day calendar_information.holiday_Easter calendar_information.holiday_Father's Day calendar_information.holiday_Flag Day calendar_information.holiday_Good Friday calendar_information.holiday_Halloween Day calendar_information.holiday_Independence Day calendar_information.holiday_Labor Day calendar_information.holiday_Lincoln's Birthday calendar_information.holiday_Martin Luther King Day calendar_information.holiday_Memorial Day calendar_information.holiday_Mother's Day calendar_information.holiday_NONE calendar_information.holiday_New Year's Day calendar_information.holiday_New Year's Eve calendar_information.holiday_Palm Sunday calendar_information.holiday_President's Day calendar_information.holiday_Saint Patrick's Day calendar_information.holiday_Saint Valentine's Day calendar_information.holiday_Thanksgiving Day calendar_information.holiday_Veteran's Day calendar_information.holiday_Washington's Birthday calendar_information.type_of_day_WEEKDAY calendar_information.type_of_day_WEEKEND
0 2021 5046 2 2 38 4046 3648 43435 556 642 45678 4776 5364 41725 13895 7906 46043 20 6 4 4 6 2 2 6 2 21560 2021-01-17 3 1792.1260 528.8185 870.0160 1490.3980 0 1 0 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 1 0 1 1 0 1 0 1 0 1 0 1 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1
1 2021 5046 2 2 38 4046 3648 43435 556 642 45678 4776 5364 41725 13895 7906 46043 20 6 4 4 6 2 2 6 2 21560 2021-01-20 3 2297.4595 793.7300 1582.0420 1750.7525 0 1 0 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 1 0 1 1 0 1 0 1 0 1 0 1 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0
2 2021 5046 2 2 38 4046 3648 43435 556 642 45678 4776 5364 41725 13895 7906 46043 20 6 4 4 6 2 2 6 2 21560 2021-01-21 3 2381.5120 829.0730 1506.6660 1727.6210 0 1 0 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 1 0 1 1 0 1 0 1 0 1 0 1 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0
3 2021 5046 2 2 38 4046 3648 43435 556 642 45678 4776 5364 41725 13895 7906 46043 20 6 4 4 6 2 2 6 2 21560 2021-01-24 4 1396.4370 456.1830 510.9370 1184.8060 0 1 0 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 1 0 1 1 0 1 0 1 0 1 0 1 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1
4 2021 5046 2 2 38 4046 3648 43435 556 642 45678 4776 5364 41725 13895 7906 46043 20 6 4 4 6 2 2 6 2 21560 2021-01-29 5 2568.2370 782.6245 1604.0325 1987.2720 0 1 0 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 1 0 1 1 0 1 0 1 0 1 0 1 0 0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0
In [ ]:
df.describe()
Out[ ]:
open_year square_feet front_door_count years_since_last_project parking_spaces x1_mile_pop x1_mile_emp x1_mile_income x1_2_mile_pop x1_2_mile_emp x1_2_mile_income x5_min_pop x5_min_emp x5_min_inc x7_min_pop x7_min_emp x7_min_inc traditional_forecourt_fueling_positions rv_lanes_fueling_positions hi_flow_lanes_fueling_positions hi_flow_lanes_fueling_positions_2 rv_lanes_fueling_positions_2 mens_toilet_count mens_urinal_count womens_toilet_count womens_sink_count calendar.fiscal_week_id_for_year daily_yoy_ndt.total_inside_sales daily_yoy_ndt.total_food_service diesel_y unleaded lottery_No lottery_Yes freal_No freal_Yes bonfire_grill_No bonfire_grill_Yes pizza_No pizza_Yes cinnabon_No cinnabon_Yes godfather_s_pizza_No ethanol_free_No ethanol_free_Yes diesel_x_Yes hi_flow_lanes_No hi_flow_lanes_Yes rv_lanes_No rv_lanes_Yes hi_flow_rv_lanes_No hi_flow_rv_lanes_Yes def_No def_Yes cat_scales_No cat_scales_Yes car_wash_No ev_charging_No rv_dumps_No rv_dumps_Yes propane_No propane_Yes traditional_forecourt_layout_In-Line traditional_forecourt_layout_Stack traditional_forecourt_stack_type_Extra-Large traditional_forecourt_stack_type_Large traditional_forecourt_stack_type_None rv_lanes_layout_In-Line rv_lanes_layout_None rv_lanes_layout_Stack rv_lanes_stack_type_HF/RV rv_lanes_stack_type_None hi_flow_lanes_layout_Combo hi_flow_lanes_layout_None hi_flow_lanes_layout_Stack hi_flow_lanes_stack_type_HF/RV hi_flow_lanes_stack_type_None hi_flow_rv_lanes_layout_Combo hi_flow_rv_lanes_layout_In-Line hi_flow_rv_lanes_layout_None hi_flow_rv_lanes_layout_Stack hi_flow_rv_lanes_stack_type_HF/RV hi_flow_rv_lanes_stack_type_None non_24_hour_No self_check_out_Yes capital_projects.soft_opening_date_2021-01-12 capital_projects.soft_opening_date_2021-01-26 capital_projects.soft_opening_date_2021-02-02 capital_projects.soft_opening_date_2021-03-30 capital_projects.soft_opening_date_2021-04-13 capital_projects.soft_opening_date_2021-05-13 capital_projects.soft_opening_date_2021-05-18 capital_projects.soft_opening_date_2021-05-25 capital_projects.soft_opening_date_2021-06-15 capital_projects.soft_opening_date_2021-06-22 capital_projects.soft_opening_date_2021-07-13 capital_projects.soft_opening_date_2021-07-20 capital_projects.soft_opening_date_2021-07-27 capital_projects.soft_opening_date_2021-08-17 capital_projects.soft_opening_date_2021-09-21 capital_projects.soft_opening_date_2021-09-28 capital_projects.soft_opening_date_2021-10-19 capital_projects.soft_opening_date_2021-11-09 capital_projects.soft_opening_date_2021-11-17 capital_projects.soft_opening_date_2021-12-07 capital_projects.soft_opening_date_2022-03-01 capital_projects.soft_opening_date_2022-03-15 capital_projects.soft_opening_date_2022-05-03 capital_projects.soft_opening_date_2022-05-10 capital_projects.soft_opening_date_2022-05-17 capital_projects.soft_opening_date_2022-06-14 capital_projects.soft_opening_date_2022-06-28 capital_projects.soft_opening_date_2022-07-12 capital_projects.soft_opening_date_2022-08-02 capital_projects.soft_opening_date_2022-08-09 capital_projects.soft_opening_date_2022-08-16 calendar.day_of_week_Friday calendar.day_of_week_Monday calendar.day_of_week_Saturday calendar.day_of_week_Sunday calendar.day_of_week_Thursday calendar.day_of_week_Tuesday calendar.day_of_week_Wednesday calendar_information.holiday_All Saint's Day calendar_information.holiday_Ascension calendar_information.holiday_Christmas Day calendar_information.holiday_Christmas Eve calendar_information.holiday_Columbus Day calendar_information.holiday_Easter calendar_information.holiday_Father's Day calendar_information.holiday_Flag Day calendar_information.holiday_Good Friday calendar_information.holiday_Halloween Day calendar_information.holiday_Independence Day calendar_information.holiday_Labor Day calendar_information.holiday_Lincoln's Birthday calendar_information.holiday_Martin Luther King Day calendar_information.holiday_Memorial Day calendar_information.holiday_Mother's Day calendar_information.holiday_NONE calendar_information.holiday_New Year's Day calendar_information.holiday_New Year's Eve calendar_information.holiday_Palm Sunday calendar_information.holiday_President's Day calendar_information.holiday_Saint Patrick's Day calendar_information.holiday_Saint Valentine's Day calendar_information.holiday_Thanksgiving Day calendar_information.holiday_Veteran's Day calendar_information.holiday_Washington's Birthday calendar_information.type_of_day_WEEKDAY calendar_information.type_of_day_WEEKEND
count 13176.000000 13176.000000 13176.0 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.0 13176.000000 13176.000000 13176.0 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.0 13176.0 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.0 13176.0 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000 13176.000000
mean 2021.333333 4968.166667 2.0 1.638889 37.361111 6886.972222 4871.333333 53679.888889 1884.027778 1551.805556 48318.305556 14926.111111 9311.861111 55649.527778 32838.222222 19473.750000 60086.166667 14.000000 2.472222 3.166667 3.166667 2.472222 2.305556 2.277778 4.500000 1.638889 26.494156 2818.539911 749.861861 1480.977994 2381.064301 0.361111 0.638889 0.027778 0.972222 0.305556 0.694444 0.611111 0.388889 0.944444 0.055556 1.0 0.277778 0.722222 1.0 0.416667 0.583333 0.388889 0.611111 0.416667 0.583333 0.388889 0.611111 0.888889 0.111111 1.0 1.0 0.666667 0.333333 0.138889 0.861111 0.750000 0.250000 0.027778 0.222222 0.750000 0.027778 0.388889 0.583333 0.583333 0.416667 0.555556 0.416667 0.027778 0.583333 0.416667 0.555556 0.027778 0.388889 0.027778 0.583333 0.416667 1.0 1.0 0.027778 0.027778 0.027778 0.055556 0.027778 0.027778 0.027778 0.055556 0.027778 0.027778 0.027778 0.027778 0.027778 0.027778 0.055556 0.027778 0.027778 0.055556 0.027778 0.027778 0.027778 0.027778 0.027778 0.027778 0.055556 0.027778 0.027778 0.027778 0.027778 0.027778 0.027778 0.142152 0.142077 0.142077 0.142077 0.142228 0.144657 0.144733 0.002732 0.002505 0.002732 0.002732 0.002732 0.002656 0.002732 0.002808 0.002656 0.002732 0.002732 0.002732 0.002732 0.002732 0.002732 0.002656 0.932225 0.002732 0.002732 0.002580 0.002732 0.002732 0.002732 0.002732 0.002732 0.002732 0.715847 0.284153
std 0.471422 575.810899 0.0 0.480341 5.912325 5583.865395 4646.163215 24224.196733 1890.000021 2478.949070 26946.309496 13200.426935 8580.164191 24275.950662 30704.249783 20421.497548 18913.655616 3.590246 2.034313 2.763959 2.763959 2.034313 0.810361 0.730747 1.500057 0.630402 14.995102 964.955381 327.116181 1360.203088 1042.922979 0.480341 0.480341 0.164342 0.164342 0.460660 0.460660 0.487517 0.487517 0.229070 0.229070 0.0 0.447920 0.447920 0.0 0.493025 0.493025 0.487517 0.487517 0.493025 0.493025 0.487517 0.487517 0.314282 0.314282 0.0 0.0 0.471422 0.471422 0.345844 0.345844 0.433029 0.433029 0.164342 0.415755 0.433029 0.164342 0.487517 0.493025 0.493025 0.493025 0.496923 0.493025 0.164342 0.493025 0.493025 0.496923 0.164342 0.487517 0.164342 0.493025 0.493025 0.0 0.0 0.164342 0.164342 0.164342 0.229070 0.164342 0.164342 0.164342 0.229070 0.164342 0.164342 0.164342 0.164342 0.164342 0.164342 0.229070 0.164342 0.164342 0.229070 0.164342 0.164342 0.164342 0.164342 0.164342 0.164342 0.229070 0.164342 0.164342 0.164342 0.164342 0.164342 0.164342 0.349220 0.349142 0.349142 0.349142 0.349297 0.351768 0.351845 0.052201 0.049985 0.052201 0.052201 0.052201 0.051473 0.052201 0.052919 0.051473 0.052201 0.052201 0.052201 0.052201 0.052201 0.052201 0.051473 0.251368 0.052201 0.052201 0.050734 0.052201 0.052201 0.052201 0.052201 0.052201 0.052201 0.451027 0.451027
min 2021.000000 2933.000000 2.0 1.000000 23.000000 0.000000 56.000000 0.000000 0.000000 31.000000 0.000000 0.000000 456.000000 0.000000 688.000000 615.000000 31540.000000 10.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 12.498500 240.180500 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.0 0.000000 0.000000 1.0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.0 1.0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.0 1.0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
25% 2021.000000 5046.000000 2.0 1.000000 34.000000 1999.750000 1849.000000 39331.250000 368.500000 558.500000 29517.750000 4763.250000 3191.000000 40702.750000 10571.750000 6865.000000 47638.250000 12.000000 0.000000 0.000000 0.000000 0.000000 2.000000 2.000000 4.000000 1.000000 14.000000 2169.199375 521.808000 387.048375 1635.273500 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 1.0 0.000000 0.000000 1.0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 1.0 1.0 0.000000 0.000000 0.000000 1.000000 0.750000 0.000000 0.000000 0.000000 0.750000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.0 1.0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
50% 2021.000000 5046.000000 2.0 2.000000 38.000000 5682.000000 4089.000000 46529.000000 1031.000000 1042.500000 45192.000000 13252.500000 6559.000000 52396.000000 25235.500000 11743.000000 53921.000000 12.000000 4.000000 5.000000 5.000000 4.000000 2.000000 2.000000 4.000000 2.000000 26.000000 2672.171250 696.304000 1020.530000 2245.206250 0.000000 1.000000 0.000000 1.000000 0.000000 1.000000 1.000000 0.000000 1.000000 0.000000 1.0 0.000000 1.000000 1.0 0.000000 1.000000 0.000000 1.000000 0.000000 1.000000 0.000000 1.000000 1.000000 0.000000 1.0 1.0 1.000000 0.000000 0.000000 1.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 1.000000 1.000000 0.000000 1.000000 0.000000 0.000000 1.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 1.0 1.0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000
75% 2022.000000 5046.000000 2.0 2.000000 41.000000 11270.750000 6079.500000 74122.250000 2791.500000 1681.250000 69691.500000 21077.000000 12290.750000 75301.750000 47331.750000 26572.250000 77828.500000 16.000000 4.000000 5.000000 5.000000 4.000000 3.000000 3.000000 6.000000 2.000000 39.000000 3290.284375 913.594500 2228.891875 2937.666375 1.000000 1.000000 0.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 0.000000 1.0 1.000000 1.000000 1.0 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 0.000000 1.0 1.0 1.000000 1.000000 0.000000 1.000000 1.000000 0.250000 0.000000 0.000000 1.000000 0.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 0.000000 1.000000 1.000000 1.000000 0.000000 1.000000 0.000000 1.000000 1.000000 1.0 1.0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.000000 1.000000
max 2022.000000 6134.000000 2.0 2.000000 49.000000 18692.000000 26077.000000 110957.000000 5923.000000 15403.000000 104730.000000 55385.000000 34199.000000 114281.000000 137979.000000 83985.000000 108534.000000 24.000000 6.000000 7.000000 7.000000 6.000000 4.000000 3.000000 6.000000 3.000000 52.000000 7172.466000 2531.662000 7632.415000 8077.233500 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.0 1.000000 1.000000 1.0 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.0 1.0 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.0 1.0 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000

Modeling Process

We will be modeling sales metrics on ETS, ARIMA, Prophet and XGBoost. We have decided to pursue these models as they can each approach a time-series forecasting business problem.

First, we will look at the seasonal decomposition of each sales metric.

Afterwards, we'll split the dataset into testing and training, with the test set consisting of six stores.

We will then use RMSE as a performance metric for each store. We will decide on the best model based on the lowest average RMSE for the sales metrics.

Seasonal Decomposition

In [ ]:
decom_df = df.copy()
In [ ]:
decom_df.set_index('calendar.calendar_day_date', inplace = True)

Inside Sales

In [ ]:
import statsmodels.api as sm
In [ ]:
# Aggregate sales data for all stores on each date
combined_sales = decom_df.groupby(decom_df.index)['daily_yoy_ndt.total_inside_sales'].mean()

# Perform seasonal decomposition for the combined sales data
result = sm.tsa.seasonal_decompose(combined_sales, model='additive')  # Change 'additive' to 'multiplicative' if necessary

# Access the decomposed components
trend = result.trend
seasonal = result.seasonal
residual = result.resid

# Plot the decomposed components for the combined sales data
plt.figure(figsize=(12, 6))
plt.suptitle('Seasonal Decomposition for Inside Sales')
plt.subplot(411)
plt.plot(combined_sales, label='Original')
plt.legend(loc='best')
plt.subplot(412)
plt.plot(trend, label='Trend')
plt.legend(loc='best')
plt.subplot(413)
plt.plot(seasonal, label='Seasonal')
plt.legend(loc='best')
plt.subplot(414)
plt.plot(residual, label='Residual')
plt.legend(loc='best')
plt.tight_layout()

plt.show()

Food Service Sales

In [ ]:
# Aggregate sales data for all stores on each date
combined_sales = decom_df.groupby(decom_df.index)['daily_yoy_ndt.total_food_service'].mean()

# Perform seasonal decomposition for the combined sales data
result = sm.tsa.seasonal_decompose(combined_sales, model='additive')  # Change 'additive' to 'multiplicative' if necessary

# Access the decomposed components
trend = result.trend
seasonal = result.seasonal
residual = result.resid

# Plot the decomposed components for the combined sales data
plt.figure(figsize=(12, 6))
plt.suptitle('Seasonal Decomposition for Food Service Sales')
plt.subplot(411)
plt.plot(combined_sales, label='Original')
plt.legend(loc='best')
plt.subplot(412)
plt.plot(trend, label='Trend')
plt.legend(loc='best')
plt.subplot(413)
plt.plot(seasonal, label='Seasonal')
plt.legend(loc='best')
plt.subplot(414)
plt.plot(residual, label='Residual')
plt.legend(loc='best')
plt.tight_layout()

Diesel Sales

In [ ]:
# Aggregate sales data for all stores on each date
combined_sales = decom_df.groupby(decom_df.index)['diesel_y'].mean()

# Perform seasonal decomposition for the combined sales data
result = sm.tsa.seasonal_decompose(combined_sales, model='additive')  # Change 'additive' to 'multiplicative' if necessary

# Access the decomposed components
trend = result.trend
seasonal = result.seasonal
residual = result.resid

# Plot the decomposed components for the combined sales data
plt.figure(figsize=(12, 6))
plt.suptitle('Seasonal Decomposition for Diesel Sales')
plt.subplot(411)
plt.plot(combined_sales, label='Original')
plt.legend(loc='best')
plt.subplot(412)
plt.plot(trend, label='Trend')
plt.legend(loc='best')
plt.subplot(413)
plt.plot(seasonal, label='Seasonal')
plt.legend(loc='best')
plt.subplot(414)
plt.plot(residual, label='Residual')
plt.legend(loc='best')
plt.tight_layout()

Unleaded Sales

In [ ]:
# Aggregate sales data for all stores on each date
combined_sales = decom_df.groupby(decom_df.index)['unleaded'].mean()

# Perform seasonal decomposition for the combined sales data
result = sm.tsa.seasonal_decompose(combined_sales, model='additive')  # Change 'additive' to 'multiplicative' if necessary

# Access the decomposed components
trend = result.trend
seasonal = result.seasonal
residual = result.resid

# Plot the decomposed components for the combined sales data
plt.figure(figsize=(12, 6))
plt.suptitle('Seasonal Decomposition for Unleaded Sales')
plt.subplot(411)
plt.plot(combined_sales, label='Original')
plt.legend(loc='best')
plt.subplot(412)
plt.plot(trend, label='Trend')
plt.legend(loc='best')
plt.subplot(413)
plt.plot(seasonal, label='Seasonal')
plt.legend(loc='best')
plt.subplot(414)
plt.plot(residual, label='Residual')
plt.legend(loc='best')
plt.tight_layout()

Splitting the Data

In [ ]:
model_df = df.copy()

model_df2 = model_df
In [ ]:
model_df['site_id_msba'].nunique()
#There are 36 unique site IDs, I will use 6 site IDs for the test dataset and 30 for training
Out[ ]:
36
In [ ]:
np.random.seed(1234)

unique_sites = model_df['site_id_msba'].unique()
np.random.shuffle(unique_sites)
random_unique_sites = unique_sites[:6]
test_sites = random_unique_sites.tolist()

print(test_sites)
#Splitting the dataset into train and test sets based on site id

stores_for_testing = test_sites
stores_for_training = [x for x in unique_sites if x not in test_sites]

train_data = model_df[model_df['site_id_msba'].isin(stores_for_training)]
test_data = model_df[model_df['site_id_msba'].isin(stores_for_testing)]
# Get unique 'site_id_msba' values from test_data
unique_site_ids = test_data['site_id_msba'].unique()

# Create a dictionary to store the separate DataFrames
test_data_dict = {}

# Iterate through unique site IDs and create separate DataFrames
for idx, site_id in enumerate(unique_site_ids, start=1):
    # Filter the test_data for the current site_id
    test_data_site = test_data[test_data['site_id_msba'] == site_id]

    # Store the filtered DataFrame in the dictionary with a numerical key
    test_data_dict[idx] = test_data_site

# Access the separate DataFrames as test_data_1, test_data_2, test_data_3, etc.
# For example, to access test_data for 'site_id_msba' 1:
test_data_1 = test_data_dict[1]
test_data_2 = test_data_dict[2]
test_data_3 = test_data_dict[3]
test_data_4 = test_data_dict[4]
test_data_5 = test_data_dict[5]
test_data_6 = test_data_dict[6]
[22540, 24535, 22750, 22015, 22260, 23905]

Modeling Process

Benchmark: Average RMSE

We are going to use these scores as benchmark. We took the average of each sales metric and used it as prediction. Compared to our test data, the performance is as follows:

Inside Sales MAE: 707.2735125491541 RMSE: 967.2567077320317

Food Service MAE: 236.37052076466694 RMSE: 298.75333424739136

Diesel MAE: 889.6733050759848 RMSE: 1003.2789422445452

Unleaded MAE: 906.8842300356473 RMSE: 1345.069038082699

In [ ]:
# List of target columns (sales metrics)
target_columns = [
    'daily_yoy_ndt.total_inside_sales',
    'daily_yoy_ndt.total_food_service',
    'diesel_y',
    'unleaded'
]

# Initializing a dictionary to store evaluation results for each metric
evaluation_results = {}

# Looping through each target column
for metric in target_columns:
    # Calculating Historical Average for the current metric
    historical_average = train_data[metric].mean()

    # Making Predictions for test data for the current metric
    test_predictions = [historical_average] * len(test_data)

    # Calculating Evaluation Metrics for the current metric
    mae = mean_absolute_error(test_data[metric], test_predictions)
    rmse = np.sqrt(mean_squared_error(test_data[metric], test_predictions))

    evaluation_results[metric] = {'MAE': mae, 'RMSE': rmse}

# Printing the evaluation results for each metric
for metric, results in evaluation_results.items():
    print(f"Metric: {metric}")
    print(f"Mean Absolute Error (MAE): {results['MAE']}")
    print(f"Root Mean Squared Error (RMSE): {results['RMSE']}")
Metric: daily_yoy_ndt.total_inside_sales
Mean Absolute Error (MAE): 762.8913028417293
Root Mean Squared Error (RMSE): 1026.818063043741
Metric: daily_yoy_ndt.total_food_service
Mean Absolute Error (MAE): 250.78304172788074
Root Mean Squared Error (RMSE): 313.4568627363107
Metric: diesel_y
Mean Absolute Error (MAE): 852.1540893284612
Root Mean Squared Error (RMSE): 936.5451291030257
Metric: unleaded
Mean Absolute Error (MAE): 997.550369918854
Root Mean Squared Error (RMSE): 1442.5594549802984

ETS

The ETS models are a family of time series models with an underlying state space model consisting of a level component, a trend component (T), a seasonal component (S), and an error term (E).

Our data shows a trend and seasonality based on the seasonal decomposition performed earlier. This is why we decided to choose ETS as one of the models to train and evaluate.

In [ ]:
train_ets = train_data.copy()
Inside Sales

Benchmark
MAE: 707.27 RMSE: 967.25

Test 1

MAE: 503.89 RMSE: 631.46

Test 2

MAE: 760.74
RMSE: 862.00

Test 3

MAE: 575.32
RMSE: 726.03

Test 4

MAE: 1554.37
RMSE: 1765.73

Test 5

MAE: 986.74
RMSE: 1119.62

Test 6

MAE: 551.14 RMSE: 692.28

In [ ]:
columns_to_remove = ['daily_yoy_ndt.total_food_service', 'diesel_y', 'unleaded']
train_inside = train_ets.drop(columns=columns_to_remove)
target1 = 'daily_yoy_ndt.total_inside_sales'
In [ ]:
model_inside = ExponentialSmoothing(train_inside[target1], seasonal='add', seasonal_periods = 365)

model_fit_inside = model_inside.fit()
In [ ]:
# Defining a function to perform the forecast, plot, and calculate errors
def forecast_and_evaluate(model, test_data, target, test_number):
    forecast = model.forecast(steps=len(test_data))
    test_data = test_data.sort_index()

    # Plotting the forecast and actual data
    plt.figure(figsize=(12, 6))
    plt.plot(test_data.index, forecast, label=f"Forecast Test {test_number}", color='blue')
    plt.plot(test_data.index, test_data[target], label=f"Actual Test {test_number}", color='green')
    plt.title(f"Forecast vs Actual {target} Test {test_number}")
    plt.xlabel("Date")
    plt.ylabel("Sales")
    plt.legend()
    plt.grid(True)
    plt.show()

    # Calculating MAE and RMSE
    mae = mean_absolute_error(test_data[target], forecast)
    rmse = np.sqrt(mean_squared_error(test_data[target], forecast))

    print(f"Mean Absolute Error (MAE) for Test {test_number}: {mae}")
    print(f"Root Mean Squared Error (RMSE) for Test {test_number}: {rmse}")

test_data_list = [test_data_1, test_data_2, test_data_3, test_data_4, test_data_5, test_data_6]

model = model_fit_inside

# Looping through the test datasets and applying the function
for i, test_data in enumerate(test_data_list, start=1):
    target = target1
    forecast_and_evaluate(model, test_data, target, i)
Mean Absolute Error (MAE) for Test 1: 503.8908219975461
Root Mean Squared Error (RMSE) for Test 1: 631.4653857366088
Mean Absolute Error (MAE) for Test 2: 760.7423194603731
Root Mean Squared Error (RMSE) for Test 2: 862.0015816336563
Mean Absolute Error (MAE) for Test 3: 575.3294234607363
Root Mean Squared Error (RMSE) for Test 3: 726.0356511615598
Mean Absolute Error (MAE) for Test 4: 1554.374186025674
Root Mean Squared Error (RMSE) for Test 4: 1765.7367360902733
Mean Absolute Error (MAE) for Test 5: 986.7465455984793
Root Mean Squared Error (RMSE) for Test 5: 1119.625825243083
Mean Absolute Error (MAE) for Test 6: 551.1477565921797
Root Mean Squared Error (RMSE) for Test 6: 692.2802525670279
Food Service

Benchmark MAE: 236.37 RMSE: 298.75

Test 1

MAE: 155.18 RMSE: 196.79

Test 2

MAE: 366.29
RMSE: 384.48

Test 3

MAE: 187.72
RMSE: 224.85

Test 4

MAE: 423.73 RMSE: 462.54

Test 5

MAE: 222.41
RMSE: 288.66

Test 6

MAE: 211.78 RMSE: 250.74

In [ ]:
columns_to_remove = ['daily_yoy_ndt.total_inside_sales', 'diesel_y', 'unleaded']
train_food = train_ets.drop(columns=columns_to_remove)
target2 = 'daily_yoy_ndt.total_food_service'
In [ ]:
model_food = ExponentialSmoothing(train_food[target2], seasonal='add', seasonal_periods = 120)

model_fit_food = model_food.fit()
In [ ]:
# Defining a function to perform the forecast, plot, and calculate errors
def forecast_and_evaluate(model, test_data, target, test_number):
    forecast = model.forecast(steps=len(test_data))
    test_data = test_data.sort_index()

    # Plotting the forecast and actual data
    plt.figure(figsize=(12, 6))
    plt.plot(test_data.index, forecast, label=f"Forecast Test {test_number}", color='blue')
    plt.plot(test_data.index, test_data[target], label=f"Actual Test {test_number}", color='green')
    plt.title(f"Forecast vs Actual {target} Test {test_number}")
    plt.xlabel("Date")
    plt.ylabel("Sales")
    plt.legend()
    plt.grid(True)
    plt.show()

    # Calculaing MAE and RMSE
    mae = mean_absolute_error(test_data[target], forecast)
    rmse = np.sqrt(mean_squared_error(test_data[target], forecast))

    print(f"Mean Absolute Error (MAE) for Test {test_number}: {mae}")
    print(f"Root Mean Squared Error (RMSE) for Test {test_number}: {rmse}")

test_data_list = [test_data_1, test_data_2, test_data_3, test_data_4, test_data_5, test_data_6]

model = model_fit_food

# Looping through the test datasets and apply the function
for i, test_data in enumerate(test_data_list, start=1):
    target = target2  # Replace with your target column name
    forecast_and_evaluate(model, test_data, target, i)
Mean Absolute Error (MAE) for Test 1: 155.184703050685
Root Mean Squared Error (RMSE) for Test 1: 196.79868253277127
Mean Absolute Error (MAE) for Test 2: 366.29711844979295
Root Mean Squared Error (RMSE) for Test 2: 384.4887700395316
Mean Absolute Error (MAE) for Test 3: 187.72100616828462
Root Mean Squared Error (RMSE) for Test 3: 224.85664254786852
Mean Absolute Error (MAE) for Test 4: 423.73179532477127
Root Mean Squared Error (RMSE) for Test 4: 462.5468758725956
Mean Absolute Error (MAE) for Test 5: 222.4155607064844
Root Mean Squared Error (RMSE) for Test 5: 288.66993993884654
Mean Absolute Error (MAE) for Test 6: 211.78316174477425
Root Mean Squared Error (RMSE) for Test 6: 250.74191963498703
Diesel

Benchmark MAE: 889.67 RMSE: 1003.27

Test 1

MAE: 297.63
RMSE: 368.73

Test 2

MAE: 372.98 RMSE: 437.90

Test 3

MAE: 1202.85 RMSE: 1385.61

Test 4

MAE: 992.33 RMSE: 1160.30

Test 5

MAE: 544.97 RMSE: 607.49

Test 6

MAE: 661.04 RMSE: 805.87

In [ ]:
columns_to_remove = ['daily_yoy_ndt.total_inside_sales','daily_yoy_ndt.total_food_service', 'unleaded']
train_diesel = train_ets.drop(columns=columns_to_remove)
train_diesel = train_diesel.groupby('calendar.calendar_day_date').mean()
target3 = 'diesel_y'
In [ ]:
model_diesel= ExponentialSmoothing(train_diesel[target3], seasonal='add', seasonal_periods = 120)

model_fit_diesel = model_diesel.fit()
In [ ]:
# Defining a function to perform the forecast, plot, and calculate errors
def forecast_and_evaluate(model, test_data, target, test_number):
    forecast = model.forecast(steps=len(test_data))
    test_data = test_data.sort_index()

    # Plotting the forecast and actual data
    plt.figure(figsize=(12, 6))
    plt.plot(test_data.index, forecast, label=f"Forecast Test {test_number}", color='blue')
    plt.plot(test_data.index, test_data[target], label=f"Actual Test {test_number}", color='green')
    plt.title(f"Forecast vs Actual {target} Test {test_number}")
    plt.xlabel("Date")
    plt.ylabel("Sales")
    plt.legend()
    plt.grid(True)
    plt.show()

    # Calculating MAE and RMSE
    mae = mean_absolute_error(test_data[target], forecast)
    rmse = np.sqrt(mean_squared_error(test_data[target], forecast))

    print(f"Mean Absolute Error (MAE) for Test {test_number}: {mae}")
    print(f"Root Mean Squared Error (RMSE) for Test {test_number}: {rmse}")

test_data_list = [test_data_1, test_data_2, test_data_3, test_data_4, test_data_5, test_data_6]

model = model_fit_diesel

# Loop through the test datasets and apply the function
for i, test_data in enumerate(test_data_list, start=1):
    target = target3  # Replace with your target column name
    forecast_and_evaluate(model, test_data, target, i)
Mean Absolute Error (MAE) for Test 1: 297.632964108849
Root Mean Squared Error (RMSE) for Test 1: 368.7300251599922
Mean Absolute Error (MAE) for Test 2: 372.9866366845219
Root Mean Squared Error (RMSE) for Test 2: 437.9025528639676
Mean Absolute Error (MAE) for Test 3: 1202.8598132541758
Root Mean Squared Error (RMSE) for Test 3: 1385.6156600062932
Mean Absolute Error (MAE) for Test 4: 992.339332314231
Root Mean Squared Error (RMSE) for Test 4: 1160.3047419446466
Mean Absolute Error (MAE) for Test 5: 544.9773257105106
Root Mean Squared Error (RMSE) for Test 5: 607.4971452835559
Mean Absolute Error (MAE) for Test 6: 661.0451902619449
Root Mean Squared Error (RMSE) for Test 6: 805.8783424195829
Unleaded

Benchmark MAE: 906.88 RMSE: 1345.06

Test 1

MAE: 779.46
RMSE: 862.54

Test 2

MAE: 3223.10 RMSE: 3459.38

Test 3

MAE: 819.70 RMSE: 994.29

Test 4

MAE: 537.34 RMSE: 635.64

Test 5

MAE: 596.21 RMSE: 694.44

Test 6

MAE: 1021.02
RMSE: 1170.13

In [ ]:
columns_to_remove = ['daily_yoy_ndt.total_inside_sales','daily_yoy_ndt.total_food_service','diesel_y' ]
train_unleaded = train_ets.drop(columns=columns_to_remove)
train_unlaeded = train_unleaded.groupby('calendar.calendar_day_date').mean()
target4 = 'unleaded'
In [ ]:
model_unleaded = ExponentialSmoothing(train_unleaded[target4], seasonal='add', seasonal_periods = 365)

model_fit_unleaded = model_unleaded.fit()
In [ ]:
# Defining a function to perform the forecast, plot, and calculate errors
def forecast_and_evaluate(model, test_data, target, test_number):
    forecast = model.forecast(steps=len(test_data))
    test_data = test_data.sort_index()

    # Plotting the forecast and actual data
    plt.figure(figsize=(12, 6))
    plt.plot(test_data.index, forecast, label=f"Forecast Test {test_number}", color='blue')
    plt.plot(test_data.index, test_data[target], label=f"Actual Test {test_number}", color='green')
    plt.title(f"Forecast vs Actual {target} Test {test_number}")
    plt.xlabel("Date")
    plt.ylabel("Sales")
    plt.legend()
    plt.grid(True)
    plt.show()

    # Calculating MAE and RMSE
    mae = mean_absolute_error(test_data[target], forecast)
    rmse = np.sqrt(mean_squared_error(test_data[target], forecast))

    print(f"Mean Absolute Error (MAE) for Test {test_number}: {mae}")
    print(f"Root Mean Squared Error (RMSE) for Test {test_number}: {rmse}")

test_data_list = [test_data_1, test_data_2, test_data_3, test_data_4, test_data_5, test_data_6]

model = model_fit_unleaded

# Looping through the test datasets and apply the function
for i, test_data in enumerate(test_data_list, start=1):
    target = target4
    forecast_and_evaluate(model, test_data, target, i)
Mean Absolute Error (MAE) for Test 1: 779.463298670218
Root Mean Squared Error (RMSE) for Test 1: 862.5460563326361
Mean Absolute Error (MAE) for Test 2: 3223.1010652083187
Root Mean Squared Error (RMSE) for Test 2: 3459.3823379178166
Mean Absolute Error (MAE) for Test 3: 819.7050168707748
Root Mean Squared Error (RMSE) for Test 3: 994.2903537618611
Mean Absolute Error (MAE) for Test 4: 537.3494224925529
Root Mean Squared Error (RMSE) for Test 4: 635.6412184956494
Mean Absolute Error (MAE) for Test 5: 596.2120432888739
Root Mean Squared Error (RMSE) for Test 5: 694.442747780334
Mean Absolute Error (MAE) for Test 6: 1021.0236796923208
Root Mean Squared Error (RMSE) for Test 6: 1170.1364082785353

ARIMA

ARIMA is a model used for forecasting future outcomes based on a historical time series. It is based on the statistical concept of serial correlation, where past data points influence future data points. ARIMA is flexible and can handle a wide range of time series data patterns, including trends, seasonality, and autocorrelation which is why we chose ARIMA as one of the models for this project.

In [ ]:
import math
from statsmodels.tsa.statespace.sarimax import SARIMAX
import statsmodels.api as sm

# train_data.set_index('calendar.calendar_day_date', inplace = True)
train_data = train_data.sort_values(by='calendar.calendar_day_date')

# test_data.set_index('calendar.calendar_day_date', inplace = True)
test_data = test_data.sort_values(by='calendar.calendar_day_date')
In [ ]:
# Function to train arima model which will be fit for each stores in the training data set

def train_arima_models(data,metric):
    store_ids = data['site_id_msba'].unique()
    models = {}

    for store_id in store_ids:
        store_data = data[data['site_id_msba'] == store_id]
        time_series = store_data[metric]

        # Train ARIMA model
        model = sm.tsa.SARIMAX(time_series, order = (2, 1, 3))
        model_fit = model.fit()

        models[store_id] = model_fit

    return models
In [ ]:
# Function to average the forecast for stores in test data set predicted by all the models fitted for each stores in train dataset
def average_forecast_for_test_stores(models, test_data,metric):
    new_store_ids = set(test_data['site_id_msba'].unique()) - set(models.keys())
    all_forecasts = []

    for store_id in new_store_ids:
        store_data = test_data[test_data['site_id_msba'] == store_id]
        time_series = store_data[metric]

        # Use the average forecast from all models for new stores
        average_forecast = np.mean([model.forecast(steps=len(time_series)) for model in models.values()], axis=0)
        all_forecasts.append(average_forecast)

    if all_forecasts:
        return all_forecasts
    else:
        return None
Inside Sales

In [ ]:
# Train ARIMA models for each store in traindf
models = train_arima_models(train_data,'daily_yoy_ndt.total_inside_sales')
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.48438D+00    |proj g|=  2.59735D-01

At iterate    5    f=  7.46213D+00    |proj g|=  3.19133D-02
 This problem is unconstrained.
At iterate   10    f=  7.46077D+00    |proj g|=  6.86163D-04

At iterate   15    f=  7.46068D+00    |proj g|=  2.98772D-02

At iterate   20    f=  7.43709D+00    |proj g|=  4.22500D-02

At iterate   25    f=  7.42408D+00    |proj g|=  1.41121D-01

At iterate   30    f=  7.42187D+00    |proj g|=  6.62148D-02

At iterate   35    f=  7.41061D+00    |proj g|=  2.77944D-01

At iterate   40    f=  7.40790D+00    |proj g|=  5.98544D-03

At iterate   45    f=  7.40732D+00    |proj g|=  9.54348D-02

At iterate   50    f=  7.40617D+00    |proj g|=  4.90310D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     71      1     0     0   4.903D-02   7.406D+00
  F =   7.4061679107221945     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  8.98998D+00    |proj g|=  1.75042D+00
 This problem is unconstrained.
At iterate    5    f=  8.70109D+00    |proj g|=  3.29048D-01

At iterate   10    f=  8.48022D+00    |proj g|=  1.40707D-01

At iterate   15    f=  8.44263D+00    |proj g|=  4.29482D-02

At iterate   20    f=  8.41311D+00    |proj g|=  3.23997D-02

At iterate   25    f=  8.39424D+00    |proj g|=  6.24364D-02

At iterate   30    f=  8.38737D+00    |proj g|=  2.75347D-02

At iterate   35    f=  8.38142D+00    |proj g|=  5.32753D-01

At iterate   40    f=  8.37879D+00    |proj g|=  5.46397D-02

At iterate   45    f=  8.37805D+00    |proj g|=  3.55351D-01

At iterate   50    f=  8.37784D+00    |proj g|=  5.53361D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     67      1     0     0   5.534D-03   8.378D+00
  F =   8.3778405132261380     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.62414D+00    |proj g|=  3.29706D-01
 This problem is unconstrained.
At iterate    5    f=  7.51421D+00    |proj g|=  1.01770D-01

At iterate   10    f=  7.50272D+00    |proj g|=  9.94936D-02

At iterate   15    f=  7.49086D+00    |proj g|=  1.64062D-02

At iterate   20    f=  7.49065D+00    |proj g|=  3.44956D-04

At iterate   25    f=  7.49059D+00    |proj g|=  4.45382D-03

At iterate   30    f=  7.48754D+00    |proj g|=  2.22888D-02

At iterate   35    f=  7.48307D+00    |proj g|=  4.72190D-03

At iterate   40    f=  7.48294D+00    |proj g|=  7.40430D-05

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     41     45      1     0     0   1.407D-05   7.483D+00
  F =   7.4829414162231132     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.53346D+00    |proj g|=  1.13444D+00
 This problem is unconstrained.
At iterate    5    f=  7.27673D+00    |proj g|=  4.95355D-02

At iterate   10    f=  7.26225D+00    |proj g|=  8.15278D-02

At iterate   15    f=  7.21499D+00    |proj g|=  1.56708D-01

At iterate   20    f=  7.17274D+00    |proj g|=  1.14466D-01

At iterate   25    f=  7.15093D+00    |proj g|=  2.52647D-01

At iterate   30    f=  7.13972D+00    |proj g|=  2.91042D-02

At iterate   35    f=  7.13683D+00    |proj g|=  4.92012D-02

At iterate   40    f=  7.12985D+00    |proj g|=  2.55699D-01

At iterate   45    f=  7.12267D+00    |proj g|=  3.84824D-02

At iterate   50    f=  7.12263D+00    |proj g|=  7.16853D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     68      1     0     0   7.169D-03   7.123D+00
  F =   7.1226339775647345     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.91169D+00    |proj g|=  3.49173D-01

 This problem is unconstrained.
At iterate    5    f=  7.73963D+00    |proj g|=  4.73623D-01

At iterate   10    f=  7.69969D+00    |proj g|=  7.30213D-02

At iterate   15    f=  7.66672D+00    |proj g|=  5.32166D-02

At iterate   20    f=  7.66048D+00    |proj g|=  1.07355D-02

At iterate   25    f=  7.66004D+00    |proj g|=  5.37686D-03

At iterate   30    f=  7.66002D+00    |proj g|=  1.99233D-03

At iterate   35    f=  7.65990D+00    |proj g|=  2.50309D-02

At iterate   40    f=  7.65683D+00    |proj g|=  6.62358D-02

At iterate   45    f=  7.65127D+00    |proj g|=  1.72474D-01

At iterate   50    f=  7.64242D+00    |proj g|=  1.10569D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     57      1     0     0   1.106D-02   7.642D+00
  F =   7.6424190523839393     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.57681D+00    |proj g|=  2.35961D+00
 This problem is unconstrained.
At iterate    5    f=  7.11657D+00    |proj g|=  1.24774D-01

At iterate   10    f=  7.03375D+00    |proj g|=  3.42524D-02

At iterate   15    f=  6.99653D+00    |proj g|=  5.26338D-01

At iterate   20    f=  6.97972D+00    |proj g|=  1.15350D-01

At iterate   25    f=  6.96094D+00    |proj g|=  1.57223D-01

At iterate   30    f=  6.95560D+00    |proj g|=  6.23086D-02

At iterate   35    f=  6.95510D+00    |proj g|=  1.08072D-03

At iterate   40    f=  6.95506D+00    |proj g|=  2.70924D-02

At iterate   45    f=  6.95502D+00    |proj g|=  1.08107D-03

At iterate   50    f=  6.95501D+00    |proj g|=  4.98609D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     59      1     0     0   4.986D-03   6.955D+00
  F =   6.9550086320588411     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.37047D+00    |proj g|=  3.68189D-01
 This problem is unconstrained.
At iterate    5    f=  7.25855D+00    |proj g|=  8.49281D-02

At iterate   10    f=  7.23846D+00    |proj g|=  7.95869D-02

At iterate   15    f=  7.22041D+00    |proj g|=  3.24500D-02

At iterate   20    f=  7.21891D+00    |proj g|=  2.01513D-02

At iterate   25    f=  7.21853D+00    |proj g|=  1.28980D-03

At iterate   30    f=  7.21812D+00    |proj g|=  2.61808D-02

At iterate   35    f=  7.20800D+00    |proj g|=  1.20704D-01

At iterate   40    f=  7.19465D+00    |proj g|=  5.67514D-03

At iterate   45    f=  7.19445D+00    |proj g|=  2.50154D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     47     53      1     0     0   8.376D-05   7.194D+00
  F =   7.1944480475664774     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.32603D+00    |proj g|=  1.87748D-01
 This problem is unconstrained.
At iterate    5    f=  7.27521D+00    |proj g|=  5.78732D-02

At iterate   10    f=  7.25819D+00    |proj g|=  3.08900D-02

At iterate   15    f=  7.25076D+00    |proj g|=  7.78955D-03

At iterate   20    f=  7.24942D+00    |proj g|=  1.85472D-02

At iterate   25    f=  7.24429D+00    |proj g|=  6.33097D-02

At iterate   30    f=  7.24047D+00    |proj g|=  8.29872D-03

At iterate   35    f=  7.24015D+00    |proj g|=  1.46808D-02

At iterate   40    f=  7.24013D+00    |proj g|=  4.39506D-04

At iterate   45    f=  7.24012D+00    |proj g|=  1.11541D-02

At iterate   50    f=  7.23875D+00    |proj g|=  9.20311D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     60      1     0     0   9.203D-02   7.239D+00
  F =   7.2387496342324784     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.02552D+00    |proj g|=  2.78079D-01

At iterate    5    f=  6.98067D+00    |proj g|=  6.23097D-02
 This problem is unconstrained.
At iterate   10    f=  6.96546D+00    |proj g|=  1.16794D-01

At iterate   15    f=  6.94645D+00    |proj g|=  2.94314D-02

At iterate   20    f=  6.94508D+00    |proj g|=  3.04123D-04

At iterate   25    f=  6.94508D+00    |proj g|=  2.25589D-04

At iterate   30    f=  6.94502D+00    |proj g|=  2.33494D-03

At iterate   35    f=  6.94496D+00    |proj g|=  4.23538D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     38     44      1     0     0   8.602D-06   6.945D+00
  F =   6.9449594626069100     

CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL            
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  8.23393D+00    |proj g|=  1.75951D+00

At iterate    5    f=  7.40710D+00    |proj g|=  6.61272D-02
 This problem is unconstrained.
At iterate   10    f=  7.31495D+00    |proj g|=  8.08083D-02

At iterate   15    f=  7.23937D+00    |proj g|=  3.48450D-01

At iterate   20    f=  7.20698D+00    |proj g|=  5.23096D-01

At iterate   25    f=  7.17619D+00    |proj g|=  3.42450D-01

At iterate   30    f=  7.17079D+00    |proj g|=  3.14347D-02

At iterate   35    f=  7.16907D+00    |proj g|=  1.60519D-01

At iterate   40    f=  7.16645D+00    |proj g|=  5.35345D-02

At iterate   45    f=  7.16500D+00    |proj g|=  8.42512D-03

At iterate   50    f=  7.16498D+00    |proj g|=  2.53113D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     59      1     0     0   2.531D-03   7.165D+00
  F =   7.1649763966709825     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.94328D+00    |proj g|=  2.57947D-01
 This problem is unconstrained.
At iterate    5    f=  6.89040D+00    |proj g|=  6.86621D-02

At iterate   10    f=  6.88549D+00    |proj g|=  3.10946D-03

At iterate   15    f=  6.88544D+00    |proj g|=  8.01281D-03

At iterate   20    f=  6.88199D+00    |proj g|=  7.82433D-02

At iterate   25    f=  6.87138D+00    |proj g|=  1.83489D-02

At iterate   30    f=  6.86549D+00    |proj g|=  5.78104D-02

At iterate   35    f=  6.84579D+00    |proj g|=  7.49255D-02

At iterate   40    f=  6.83544D+00    |proj g|=  9.10603D-02

At iterate   45    f=  6.83106D+00    |proj g|=  6.92080D-02

At iterate   50    f=  6.82980D+00    |proj g|=  6.70561D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     70      1     0     0   6.706D-02   6.830D+00
  F =   6.8297951387600477     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.02665D+00    |proj g|=  4.40582D-01
 This problem is unconstrained.
At iterate    5    f=  6.95388D+00    |proj g|=  9.60530D-02

At iterate   10    f=  6.94393D+00    |proj g|=  4.68748D-03

At iterate   15    f=  6.93764D+00    |proj g|=  7.30707D-02

At iterate   20    f=  6.91992D+00    |proj g|=  2.25756D-01

At iterate   25    f=  6.86700D+00    |proj g|=  2.85611D-02

At iterate   30    f=  6.84812D+00    |proj g|=  2.79656D-01

At iterate   35    f=  6.83578D+00    |proj g|=  1.62464D-01

At iterate   40    f=  6.83474D+00    |proj g|=  1.19075D-02

At iterate   45    f=  6.83358D+00    |proj g|=  1.01263D-01

At iterate   50    f=  6.83330D+00    |proj g|=  9.79147D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     65      1     0     0   9.791D-03   6.833D+00
  F =   6.8332969498324694     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.38330D+00    |proj g|=  2.14501D-01

At iterate    5    f=  7.33688D+00    |proj g|=  7.69818D-02
 This problem is unconstrained.
At iterate   10    f=  7.32825D+00    |proj g|=  2.33636D-02

At iterate   15    f=  7.31918D+00    |proj g|=  3.45124D-01

At iterate   20    f=  7.29856D+00    |proj g|=  1.27771D-01

At iterate   25    f=  7.29449D+00    |proj g|=  6.24532D-02

At iterate   30    f=  7.29427D+00    |proj g|=  1.11751D-03

At iterate   35    f=  7.29427D+00    |proj g|=  7.81907D-04

At iterate   40    f=  7.29425D+00    |proj g|=  7.75062D-03

At iterate   45    f=  7.29403D+00    |proj g|=  6.14445D-02

At iterate   50    f=  7.29163D+00    |proj g|=  1.37898D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     58      1     0     0   1.379D-02   7.292D+00
  F =   7.2916266992609753     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.40550D+00    |proj g|=  1.78591D+00
 This problem is unconstrained.
At iterate    5    f=  7.04721D+00    |proj g|=  1.40501D-01

At iterate   10    f=  6.99116D+00    |proj g|=  5.05348D-02

At iterate   15    f=  6.97390D+00    |proj g|=  2.07224D-01

At iterate   20    f=  6.93616D+00    |proj g|=  1.26952D-01

At iterate   25    f=  6.92339D+00    |proj g|=  4.73095D-01

At iterate   30    f=  6.91580D+00    |proj g|=  8.09154D-02

At iterate   35    f=  6.91162D+00    |proj g|=  1.05971D-02

At iterate   40    f=  6.91144D+00    |proj g|=  1.34008D-02

At iterate   45    f=  6.91142D+00    |proj g|=  8.43272D-03

At iterate   50    f=  6.91117D+00    |proj g|=  3.88996D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     64      1     0     0   3.890D-02   6.911D+00
  F =   6.9111663710663791     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.10363D+00    |proj g|=  2.33872D+00
 This problem is unconstrained.
At iterate    5    f=  6.93005D+00    |proj g|=  2.35268D-01

At iterate   10    f=  6.84765D+00    |proj g|=  1.36344D+00

At iterate   15    f=  6.80324D+00    |proj g|=  1.91381D-01

At iterate   20    f=  6.79276D+00    |proj g|=  3.44418D-01

At iterate   25    f=  6.78997D+00    |proj g|=  9.96926D-03

At iterate   30    f=  6.78196D+00    |proj g|=  4.47409D-02

At iterate   35    f=  6.77540D+00    |proj g|=  4.89776D-02

At iterate   40    f=  6.77517D+00    |proj g|=  1.97961D-03

At iterate   45    f=  6.77516D+00    |proj g|=  3.62569D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     48     60      1     0     0   4.990D-02   6.775D+00
  F =   6.7751369445374117     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.57563D+00    |proj g|=  2.93390D+00
 This problem is unconstrained.
At iterate    5    f=  7.36239D+00    |proj g|=  1.56803D-01

At iterate   10    f=  7.32739D+00    |proj g|=  1.91992D-01

At iterate   15    f=  7.31893D+00    |proj g|=  2.71572D-01

At iterate   20    f=  7.29583D+00    |proj g|=  2.50962D-02

At iterate   25    f=  7.29549D+00    |proj g|=  9.55790D-02

At iterate   30    f=  7.28335D+00    |proj g|=  2.66297D-01

At iterate   35    f=  7.26743D+00    |proj g|=  5.18138D-01

At iterate   40    f=  7.26679D+00    |proj g|=  1.10175D-01

At iterate   45    f=  7.26643D+00    |proj g|=  2.25338D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     49     60      1     0     0   9.449D-04   7.266D+00
  F =   7.2664310505484062     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
 This problem is unconstrained.
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.07053D+00    |proj g|=  2.38483D-01

At iterate    5    f=  7.04238D+00    |proj g|=  1.17717D-02

At iterate   10    f=  7.03975D+00    |proj g|=  8.41761D-03

At iterate   15    f=  7.03681D+00    |proj g|=  3.90005D-02

At iterate   20    f=  7.02116D+00    |proj g|=  3.23455D-02

At iterate   25    f=  7.00668D+00    |proj g|=  3.88395D-02

At iterate   30    f=  6.99407D+00    |proj g|=  4.52354D-02

At iterate   35    f=  6.98119D+00    |proj g|=  5.43276D-02

At iterate   40    f=  6.97767D+00    |proj g|=  9.28497D-02

At iterate   45    f=  6.97691D+00    |proj g|=  8.27639D-03

At iterate   50    f=  6.97687D+00    |proj g|=  9.96629D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     66      1     0     0   9.966D-04   6.977D+00
  F =   6.9768690545222887     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.78124D+00    |proj g|=  8.90437D-01
 This problem is unconstrained.
At iterate    5    f=  7.56209D+00    |proj g|=  5.03099D-02

At iterate   10    f=  7.55441D+00    |proj g|=  5.78593D-03

At iterate   15    f=  7.52375D+00    |proj g|=  1.30204D-01

At iterate   20    f=  7.50447D+00    |proj g|=  8.91092D-02

At iterate   25    f=  7.49612D+00    |proj g|=  1.94058D-02

At iterate   30    f=  7.49522D+00    |proj g|=  7.83302D-03

At iterate   35    f=  7.49435D+00    |proj g|=  2.84067D-02

At iterate   40    f=  7.49428D+00    |proj g|=  4.49160D-04

At iterate   45    f=  7.49427D+00    |proj g|=  5.07215D-03

At iterate   50    f=  7.49404D+00    |proj g|=  3.64523D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     62      1     0     0   3.645D-02   7.494D+00
  F =   7.4940437795179644     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.72685D+00    |proj g|=  1.75912D+00
 This problem is unconstrained.
At iterate    5    f=  7.37821D+00    |proj g|=  8.79926D-02

At iterate   10    f=  7.33898D+00    |proj g|=  2.27040D-01

At iterate   15    f=  7.28105D+00    |proj g|=  1.73600D-01

At iterate   20    f=  7.26329D+00    |proj g|=  3.29124D-01

At iterate   25    f=  7.24746D+00    |proj g|=  1.30900D-01

At iterate   30    f=  7.24128D+00    |proj g|=  2.70304D-02

At iterate   35    f=  7.23955D+00    |proj g|=  2.50753D-01

At iterate   40    f=  7.23917D+00    |proj g|=  2.14967D-01

At iterate   45    f=  7.23854D+00    |proj g|=  1.15438D-01

At iterate   50    f=  7.23794D+00    |proj g|=  3.65971D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     66      1     0     0   3.660D-01   7.238D+00
  F =   7.2379435405462127     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
 This problem is unconstrained.
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.93700D+00    |proj g|=  1.22575D+00

At iterate    5    f=  7.63652D+00    |proj g|=  4.78510D-02

At iterate   10    f=  7.62893D+00    |proj g|=  5.17366D-02

At iterate   15    f=  7.60473D+00    |proj g|=  1.33060D-01

At iterate   20    f=  7.56690D+00    |proj g|=  4.95907D-02

At iterate   25    f=  7.52292D+00    |proj g|=  1.48216D-01

At iterate   30    f=  7.50303D+00    |proj g|=  4.57860D-02

At iterate   35    f=  7.49878D+00    |proj g|=  1.01228D-01

At iterate   40    f=  7.49520D+00    |proj g|=  1.47425D-01

At iterate   45    f=  7.49213D+00    |proj g|=  2.69130D-02

At iterate   50    f=  7.49100D+00    |proj g|=  8.03474D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     65      1     0     0   8.035D-02   7.491D+00
  F =   7.4910021166206713     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.33316D+00    |proj g|=  2.04003D-01
 This problem is unconstrained.
At iterate    5    f=  7.30704D+00    |proj g|=  2.03414D-01

At iterate   10    f=  7.26764D+00    |proj g|=  3.71383D-02

At iterate   15    f=  7.24693D+00    |proj g|=  6.73123D-02

At iterate   20    f=  7.23813D+00    |proj g|=  2.69973D-02

At iterate   25    f=  7.23235D+00    |proj g|=  3.38649D-02

At iterate   30    f=  7.22786D+00    |proj g|=  1.09363D-01

At iterate   35    f=  7.22481D+00    |proj g|=  1.19987D-01

At iterate   40    f=  7.22290D+00    |proj g|=  4.16953D-02

At iterate   45    f=  7.22147D+00    |proj g|=  5.58398D-02

At iterate   50    f=  7.22036D+00    |proj g|=  2.66891D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     67      1     0     0   2.669D-01   7.220D+00
  F =   7.2203557458597647     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
 This problem is unconstrained.
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  8.92778D+00    |proj g|=  2.47444D+00

At iterate    5    f=  7.60627D+00    |proj g|=  1.02487D-01

At iterate   10    f=  7.57040D+00    |proj g|=  3.23423D-02

At iterate   15    f=  7.55565D+00    |proj g|=  3.55851D-02

At iterate   20    f=  7.54325D+00    |proj g|=  1.06197D-01

At iterate   25    f=  7.54236D+00    |proj g|=  1.26293D-02

At iterate   30    f=  7.54175D+00    |proj g|=  2.03891D-04

At iterate   35    f=  7.54175D+00    |proj g|=  2.55314D-03

At iterate   40    f=  7.54157D+00    |proj g|=  7.61433D-02

At iterate   45    f=  7.53920D+00    |proj g|=  3.01174D-02

At iterate   50    f=  7.53911D+00    |proj g|=  7.80581D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     52      1     0     0   7.806D-04   7.539D+00
  F =   7.5391108002884790     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  9.11994D+00    |proj g|=  2.33162D+00

At iterate    5    f=  8.69583D+00    |proj g|=  4.63965D-01

At iterate   10    f=  8.45391D+00    |proj g|=  1.18818D-01
 This problem is unconstrained.
At iterate   15    f=  8.40923D+00    |proj g|=  1.60266D-02

At iterate   20    f=  8.39367D+00    |proj g|=  2.68724D-01

At iterate   25    f=  8.37113D+00    |proj g|=  2.86137D-02

At iterate   30    f=  8.36892D+00    |proj g|=  1.24420D-01

At iterate   35    f=  8.36750D+00    |proj g|=  6.90321D-02

At iterate   40    f=  8.36676D+00    |proj g|=  7.26740D-02

At iterate   45    f=  8.36607D+00    |proj g|=  7.04836D-02

At iterate   50    f=  8.36555D+00    |proj g|=  4.94644D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     69      1     0     0   4.946D-02   8.366D+00
  F =   8.3655454988711089     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.29775D+00    |proj g|=  2.87511D-01
 This problem is unconstrained.
At iterate    5    f=  7.19720D+00    |proj g|=  3.19269D-02

At iterate   10    f=  7.16318D+00    |proj g|=  1.89726D-01

At iterate   15    f=  7.12738D+00    |proj g|=  8.60300D-02

At iterate   20    f=  7.12332D+00    |proj g|=  1.17071D-02

At iterate   25    f=  7.12119D+00    |proj g|=  1.66512D-01

At iterate   30    f=  7.11873D+00    |proj g|=  2.22687D-03

At iterate   35    f=  7.11869D+00    |proj g|=  9.42393D-04

At iterate   40    f=  7.11833D+00    |proj g|=  1.19876D-01

At iterate   45    f=  7.10156D+00    |proj g|=  2.04907D-01

At iterate   50    f=  7.09472D+00    |proj g|=  1.17671D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     65      1     0     0   1.177D-01   7.095D+00
  F =   7.0947230805113897     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.43048D+00    |proj g|=  3.40124D-01

At iterate    5    f=  7.28375D+00    |proj g|=  1.30065D-01
 This problem is unconstrained.
At iterate   10    f=  7.26146D+00    |proj g|=  5.97545D-02

At iterate   15    f=  7.25150D+00    |proj g|=  3.69944D-02

At iterate   20    f=  7.25044D+00    |proj g|=  4.86286D-02

At iterate   25    f=  7.24988D+00    |proj g|=  4.91438D-04

At iterate   30    f=  7.24987D+00    |proj g|=  8.22655D-04

At iterate   35    f=  7.24822D+00    |proj g|=  7.70017D-02

At iterate   40    f=  7.24496D+00    |proj g|=  1.78946D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     42     50      1     0     0   5.344D-05   7.245D+00
  F =   7.2449617643088766     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.56985D+00    |proj g|=  3.95648D-01

At iterate    5    f=  7.43541D+00    |proj g|=  9.98055D-02
 This problem is unconstrained.
At iterate   10    f=  7.40962D+00    |proj g|=  5.08774D-02

At iterate   15    f=  7.40298D+00    |proj g|=  7.63190D-03

At iterate   20    f=  7.40291D+00    |proj g|=  5.05745D-04

At iterate   25    f=  7.40277D+00    |proj g|=  1.31386D-02

At iterate   30    f=  7.39994D+00    |proj g|=  6.10537D-02

At iterate   35    f=  7.38831D+00    |proj g|=  4.39835D-02

At iterate   40    f=  7.38734D+00    |proj g|=  1.20379D-03

At iterate   45    f=  7.38734D+00    |proj g|=  3.93880D-06

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     45     51      1     0     0   3.939D-06   7.387D+00
  F =   7.3873407850533024     

CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL            
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.39632D+00    |proj g|=  2.21585D-01

At iterate    5    f=  7.37974D+00    |proj g|=  5.32483D-02
 This problem is unconstrained.
At iterate   10    f=  7.33904D+00    |proj g|=  4.70911D-02

At iterate   15    f=  7.30996D+00    |proj g|=  2.23980D-01

At iterate   20    f=  7.28920D+00    |proj g|=  5.51746D-02

At iterate   25    f=  7.26693D+00    |proj g|=  6.79954D-02

At iterate   30    f=  7.25801D+00    |proj g|=  1.72682D-01

At iterate   35    f=  7.25440D+00    |proj g|=  9.75273D-02

At iterate   40    f=  7.25320D+00    |proj g|=  4.36706D-02

At iterate   45    f=  7.25047D+00    |proj g|=  1.27047D-01

At iterate   50    f=  7.24994D+00    |proj g|=  2.29191D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     62      1     0     0   2.292D-02   7.250D+00
  F =   7.2499444660853269     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.98788D+00    |proj g|=  6.20350D-01

At iterate    5    f=  7.80813D+00    |proj g|=  1.74243D-01
 This problem is unconstrained.
At iterate   10    f=  7.77849D+00    |proj g|=  5.22562D-02

At iterate   15    f=  7.75419D+00    |proj g|=  1.11738D-01

At iterate   20    f=  7.73940D+00    |proj g|=  7.45770D-03

At iterate   25    f=  7.73759D+00    |proj g|=  3.57404D-03

At iterate   30    f=  7.73758D+00    |proj g|=  4.41445D-04

At iterate   35    f=  7.73745D+00    |proj g|=  4.08158D-03

At iterate   40    f=  7.73085D+00    |proj g|=  1.13311D-01

At iterate   45    f=  7.71347D+00    |proj g|=  4.18589D-02

At iterate   50    f=  7.71171D+00    |proj g|=  2.79128D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     62      1     0     0   2.791D-03   7.712D+00
  F =   7.7117132906856218     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.49373D+00    |proj g|=  6.14849D-01

At iterate    5    f=  7.35646D+00    |proj g|=  9.97689D-02
 This problem is unconstrained.
At iterate   10    f=  7.27311D+00    |proj g|=  1.06199D-01

At iterate   15    f=  7.24781D+00    |proj g|=  7.40537D-02

At iterate   20    f=  7.24066D+00    |proj g|=  2.62164D-02

At iterate   25    f=  7.23847D+00    |proj g|=  2.34619D-03

At iterate   30    f=  7.23842D+00    |proj g|=  3.46134D-03

At iterate   35    f=  7.23837D+00    |proj g|=  2.96080D-02

At iterate   40    f=  7.23811D+00    |proj g|=  1.27964D-02

At iterate   45    f=  7.22838D+00    |proj g|=  4.19625D-01

At iterate   50    f=  7.21504D+00    |proj g|=  2.30213D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     65      1     0     0   2.302D-01   7.215D+00
  F =   7.2150419818914422     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.66041D+00    |proj g|=  1.83079D+00

At iterate    5    f=  7.33443D+00    |proj g|=  5.66278D-02

At iterate   10    f=  7.31281D+00    |proj g|=  2.75093D-02
 This problem is unconstrained.
At iterate   15    f=  7.27377D+00    |proj g|=  2.63778D-01

At iterate   20    f=  7.25534D+00    |proj g|=  1.14406D-01

At iterate   25    f=  7.25240D+00    |proj g|=  6.28415D-03

At iterate   30    f=  7.24997D+00    |proj g|=  5.64403D-02

At iterate   35    f=  7.24856D+00    |proj g|=  5.39080D-03

At iterate   40    f=  7.24853D+00    |proj g|=  1.12870D-03

At iterate   45    f=  7.24828D+00    |proj g|=  5.57054D-02

At iterate   50    f=  7.24264D+00    |proj g|=  5.01017D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     64      1     0     0   5.010D-02   7.243D+00
  F =   7.2426384956369292     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
In [ ]:
# Make an average forecast for store IDs in the test dataset that are not in the training dataset
test_store_forecasts = average_forecast_for_test_stores(models, test_data,'daily_yoy_ndt.total_inside_sales')

# if test_store_forecasts is not None:
#     for store_id, forecast in zip(set(test_data['site_id_msba'].unique()) - set(models.keys()), test_store_forecasts):
#         print(f'Average Forecast for Store {store_id}:\n{forecast}')
# else:
#     print('No matching models found in the training data for the new test data store IDs.')
In [ ]:
# Plot the actual vs predicted values of Inside Sales for each stores in test set
if test_store_forecasts is not None:
    for store_id, forecast in zip(set(test_data['site_id_msba'].unique()) - set(models.keys()), test_store_forecasts):
        store_data = test_data[test_data['site_id_msba'] == store_id]
        actual_data = store_data['daily_yoy_ndt.total_inside_sales']
        time_index = range(1, len(actual_data) + 1)
        plt.figure(figsize=(10, 6))
        plt.plot(time_index, actual_data, label='Actual', linestyle='-', color='blue')
        plt.plot(time_index, forecast, label='Predicted', linestyle='-', color='red')
        plt.title(f'Actual vs. Predicted Inside Sales for Store {store_id}')
        plt.xlabel('Time Period')
        plt.ylabel('Sales')
        plt.legend()
        plt.grid(True)
        plt.show()
In [ ]:
# Evaluate the prediction error metrics for Inside Sales
results = {}
if test_store_forecasts is not None:
    for store_id, forecast in zip(set(test_data['site_id_msba'].unique()) - set(models.keys()), test_store_forecasts):
        store_data = test_data[test_data['site_id_msba'] == store_id]
        actual_data = store_data['daily_yoy_ndt.total_inside_sales']
        # Calculate the Mean Squared Error (MSE) for the predictions
        mse = mean_squared_error(actual_data, forecast)

        # Calculate the Root Mean Squared Error (RMSE)
        rmse = math.sqrt(mse)

        # Store the results in the dictionary
        results['daily_yoy_ndt.total_inside_sales'] = {
            'Predictions': forecast,
            'MSE': mse,
            'RMSE': rmse
        }

        print(f"RMSE of Inside sales for Store {store_id}: {rmse}")
        print('\n')
RMSE of Inside sales for Store 24535: 607.3938326278114


Food Service

In [ ]:
# Train ARIMA models for each store in traindf
models = train_arima_models(train_data,'daily_yoy_ndt.total_food_service')
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.49407D+00    |proj g|=  5.48050D-01
 This problem is unconstrained.
At iterate    5    f=  6.39883D+00    |proj g|=  9.38937D-02

At iterate   10    f=  6.38988D+00    |proj g|=  4.19470D-02

At iterate   15    f=  6.36313D+00    |proj g|=  2.47800D-02

At iterate   20    f=  6.35748D+00    |proj g|=  2.64614D-02

At iterate   25    f=  6.34916D+00    |proj g|=  5.37212D-02

At iterate   30    f=  6.34644D+00    |proj g|=  1.24496D-02

At iterate   35    f=  6.34637D+00    |proj g|=  3.82772D-03

At iterate   40    f=  6.34632D+00    |proj g|=  7.26029D-03

At iterate   45    f=  6.34185D+00    |proj g|=  4.05133D-02

At iterate   50    f=  6.33666D+00    |proj g|=  2.51620D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     69      1     0     0   2.516D-02   6.337D+00
  F =   6.3366646343398552     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  8.04784D+00    |proj g|=  1.76267D+00

At iterate    5    f=  7.74583D+00    |proj g|=  3.51520D-01

At iterate   10    f=  7.54233D+00    |proj g|=  1.25093D-01
 This problem is unconstrained.
At iterate   15    f=  7.47402D+00    |proj g|=  9.16569D-02

At iterate   20    f=  7.45483D+00    |proj g|=  1.12106D-01

At iterate   25    f=  7.45446D+00    |proj g|=  9.83983D-04

At iterate   30    f=  7.45444D+00    |proj g|=  2.21363D-02

At iterate   35    f=  7.45330D+00    |proj g|=  1.85078D-01

At iterate   40    f=  7.43915D+00    |proj g|=  2.91135D-01

At iterate   45    f=  7.35693D+00    |proj g|=  2.48597D-01

At iterate   50    f=  7.35551D+00    |proj g|=  5.28481D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     61      1     0     0   5.285D-02   7.356D+00
  F =   7.3555131308083439     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.58945D+00    |proj g|=  8.69790D-01

At iterate    5    f=  6.38543D+00    |proj g|=  1.75339D-02

At iterate   10    f=  6.38441D+00    |proj g|=  5.50779D-03
 This problem is unconstrained.
At iterate   15    f=  6.38192D+00    |proj g|=  9.78468D-02

At iterate   20    f=  6.35666D+00    |proj g|=  2.00171D-02

At iterate   25    f=  6.30819D+00    |proj g|=  2.01731D-01

At iterate   30    f=  6.29578D+00    |proj g|=  1.52351D-01

At iterate   35    f=  6.28412D+00    |proj g|=  1.78397D-01

At iterate   40    f=  6.27953D+00    |proj g|=  1.19259D-01

At iterate   45    f=  6.26771D+00    |proj g|=  1.13086D-01

At iterate   50    f=  6.26529D+00    |proj g|=  5.90390D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     71      1     0     0   5.904D-02   6.265D+00
  F =   6.2652929069260663     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.38493D+00    |proj g|=  3.66069D-01
 This problem is unconstrained.
At iterate    5    f=  6.22684D+00    |proj g|=  7.42388D-02

At iterate   10    f=  6.20246D+00    |proj g|=  1.04405D-01

At iterate   15    f=  6.18925D+00    |proj g|=  1.54792D-02

At iterate   20    f=  6.18902D+00    |proj g|=  4.56765D-03

At iterate   25    f=  6.18895D+00    |proj g|=  2.34946D-03

At iterate   30    f=  6.18836D+00    |proj g|=  3.79296D-02

At iterate   35    f=  6.18015D+00    |proj g|=  3.38675D-02

At iterate   40    f=  6.17535D+00    |proj g|=  1.51085D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     44     55      1     0     0   3.991D-05   6.175D+00
  F =   6.1753057832920382     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.02971D+00    |proj g|=  7.67082D-01

At iterate    5    f=  6.76016D+00    |proj g|=  7.41828D-02

At iterate   10    f=  6.75160D+00    |proj g|=  4.61143D-02
 This problem is unconstrained.
At iterate   15    f=  6.73366D+00    |proj g|=  1.48502D-02

At iterate   20    f=  6.71669D+00    |proj g|=  4.29683D-02

At iterate   25    f=  6.71394D+00    |proj g|=  2.89896D-03

At iterate   30    f=  6.71379D+00    |proj g|=  2.95844D-03

At iterate   35    f=  6.70568D+00    |proj g|=  2.46771D-02

At iterate   40    f=  6.69210D+00    |proj g|=  6.47479D-03

At iterate   45    f=  6.69205D+00    |proj g|=  8.01484D-05

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     45     55      1     0     0   8.015D-05   6.692D+00
  F =   6.6920532046422059     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

 This problem is unconstrained.
Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  5.98448D+00    |proj g|=  1.12186D-01

At iterate    5    f=  5.93363D+00    |proj g|=  3.77101D-02

At iterate   10    f=  5.91194D+00    |proj g|=  6.46100D-02

At iterate   15    f=  5.89827D+00    |proj g|=  1.48366D-02

At iterate   20    f=  5.89783D+00    |proj g|=  2.13139D-03

At iterate   25    f=  5.89767D+00    |proj g|=  1.08121D-02

At iterate   30    f=  5.89497D+00    |proj g|=  7.76010D-03

At iterate   35    f=  5.89463D+00    |proj g|=  2.72471D-05

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     36     42      1     0     0   1.029D-05   5.895D+00
  F =   5.8946345589767830     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.32858D+00    |proj g|=  7.20828D-01
 This problem is unconstrained.
At iterate    5    f=  6.11262D+00    |proj g|=  7.35426D-02

At iterate   10    f=  6.08754D+00    |proj g|=  8.34065D-02

At iterate   15    f=  6.06521D+00    |proj g|=  6.29308D-02

At iterate   20    f=  6.06412D+00    |proj g|=  4.84700D-03

At iterate   25    f=  6.06141D+00    |proj g|=  4.43929D-02

At iterate   30    f=  6.04597D+00    |proj g|=  7.98341D-02

At iterate   35    f=  6.03703D+00    |proj g|=  4.83055D-02

At iterate   40    f=  6.03487D+00    |proj g|=  1.46566D-02

At iterate   45    f=  6.02772D+00    |proj g|=  1.43935D-01

At iterate   50    f=  6.02251D+00    |proj g|=  6.85224D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     68      1     0     0   6.852D-03   6.023D+00
  F =   6.0225135820692675     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  5.95657D+00    |proj g|=  1.66954D-01

At iterate    5    f=  5.92792D+00    |proj g|=  4.34285D-02
 This problem is unconstrained.
At iterate   10    f=  5.90254D+00    |proj g|=  6.35266D-02

At iterate   15    f=  5.88834D+00    |proj g|=  2.50673D-02

At iterate   20    f=  5.88518D+00    |proj g|=  3.45326D-02

At iterate   25    f=  5.87638D+00    |proj g|=  2.37915D-01

At iterate   30    f=  5.87451D+00    |proj g|=  3.62275D-03

At iterate   35    f=  5.87426D+00    |proj g|=  5.63349D-02

At iterate   40    f=  5.86952D+00    |proj g|=  2.62121D-02

At iterate   45    f=  5.86864D+00    |proj g|=  2.57507D-02

At iterate   50    f=  5.86837D+00    |proj g|=  2.06276D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     62      1     0     0   2.063D-02   5.868D+00
  F =   5.8683733161892100     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  5.76367D+00    |proj g|=  3.37585D-01
 This problem is unconstrained.
At iterate    5    f=  5.72425D+00    |proj g|=  6.72240D-02

At iterate   10    f=  5.71865D+00    |proj g|=  1.02637D-02

At iterate   15    f=  5.71258D+00    |proj g|=  5.11668D-02

At iterate   20    f=  5.67133D+00    |proj g|=  9.83489D-02

At iterate   25    f=  5.62263D+00    |proj g|=  3.65690D-02

At iterate   30    f=  5.60373D+00    |proj g|=  4.14233D-01

At iterate   35    f=  5.59298D+00    |proj g|=  2.56823D-02

At iterate   40    f=  5.58819D+00    |proj g|=  8.28286D-02

At iterate   45    f=  5.58632D+00    |proj g|=  1.47504D-01

At iterate   50    f=  5.58226D+00    |proj g|=  2.55119D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     75      1     0     0   2.551D-01   5.582D+00
  F =   5.5822559535019582     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.02868D+00    |proj g|=  4.28763D-01

At iterate    5    f=  5.93444D+00    |proj g|=  4.21693D-02
 This problem is unconstrained.
At iterate   10    f=  5.93264D+00    |proj g|=  4.04592D-02

At iterate   15    f=  5.92378D+00    |proj g|=  3.37340D-02

At iterate   20    f=  5.91064D+00    |proj g|=  1.04566D-01

At iterate   25    f=  5.90450D+00    |proj g|=  2.33656D-02

At iterate   30    f=  5.90182D+00    |proj g|=  9.94546D-02

At iterate   35    f=  5.90004D+00    |proj g|=  5.28326D-03

At iterate   40    f=  5.89995D+00    |proj g|=  2.38030D-02

At iterate   45    f=  5.89583D+00    |proj g|=  3.59104D-02

At iterate   50    f=  5.89281D+00    |proj g|=  2.37327D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     66      1     0     0   2.373D-01   5.893D+00
  F =   5.8928109564456195     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.09144D+00    |proj g|=  1.77582D+00

 This problem is unconstrained.
At iterate    5    f=  5.75701D+00    |proj g|=  9.23390D-02

At iterate   10    f=  5.69638D+00    |proj g|=  1.26362D-01

At iterate   15    f=  5.68810D+00    |proj g|=  1.07189D-01

At iterate   20    f=  5.66460D+00    |proj g|=  1.09417D-01

At iterate   25    f=  5.65718D+00    |proj g|=  3.58785D-02

At iterate   30    f=  5.65528D+00    |proj g|=  1.80886D-01

At iterate   35    f=  5.65160D+00    |proj g|=  5.20391D-01

At iterate   40    f=  5.64937D+00    |proj g|=  2.26163D-01

At iterate   45    f=  5.64641D+00    |proj g|=  6.23602D-01

At iterate   50    f=  5.62971D+00    |proj g|=  4.75839D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     64      1     0     0   4.758D-01   5.630D+00
  F =   5.6297136699686261     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  5.75862D+00    |proj g|=  3.29621D-01

At iterate    5    f=  5.68067D+00    |proj g|=  1.21507D-01

At iterate   10    f=  5.67453D+00    |proj g|=  5.41919D-03

At iterate   15    f=  5.67314D+00    |proj g|=  3.93787D-02
 This problem is unconstrained.
At iterate   20    f=  5.66831D+00    |proj g|=  1.74136D-02

At iterate   25    f=  5.66345D+00    |proj g|=  1.65034D-02

At iterate   30    f=  5.66269D+00    |proj g|=  1.68475D-03

At iterate   35    f=  5.66164D+00    |proj g|=  3.11162D-02

At iterate   40    f=  5.66085D+00    |proj g|=  1.24791D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     44     55      1     0     0   2.764D-05   5.661D+00
  F =   5.6608491854272653     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.27920D+00    |proj g|=  7.05382D-02

At iterate    5    f=  6.26141D+00    |proj g|=  1.61402D-01
 This problem is unconstrained.
At iterate   10    f=  6.25481D+00    |proj g|=  2.44342D-02

At iterate   15    f=  6.24688D+00    |proj g|=  3.32679D-02

At iterate   20    f=  6.23912D+00    |proj g|=  2.40464D-02

At iterate   25    f=  6.23693D+00    |proj g|=  1.16500D-02

At iterate   30    f=  6.23690D+00    |proj g|=  8.14444D-04

At iterate   35    f=  6.23596D+00    |proj g|=  1.87845D-02

At iterate   40    f=  6.23383D+00    |proj g|=  2.44125D-02

At iterate   45    f=  6.23376D+00    |proj g|=  4.93649D-05

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     45     55      1     0     0   4.936D-05   6.234D+00
  F =   6.2337587928139362     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  5.96567D+00    |proj g|=  4.44459D-01

At iterate    5    f=  5.90240D+00    |proj g|=  1.06652D-01

At iterate   10    f=  5.85845D+00    |proj g|=  3.33956D-02
 This problem is unconstrained.
At iterate   15    f=  5.83562D+00    |proj g|=  2.00072D-01

At iterate   20    f=  5.82678D+00    |proj g|=  5.39778D-02

At iterate   25    f=  5.82296D+00    |proj g|=  6.31521D-02

At iterate   30    f=  5.82155D+00    |proj g|=  1.04133D-01

At iterate   35    f=  5.82097D+00    |proj g|=  1.94469D-01

At iterate   40    f=  5.81965D+00    |proj g|=  2.14893D-01

At iterate   45    f=  5.81892D+00    |proj g|=  8.28611D-02

At iterate   50    f=  5.81891D+00    |proj g|=  7.07250D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     69      1     0     0   7.073D-03   5.819D+00
  F =   5.8189105214727768     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  5.78491D+00    |proj g|=  1.12209D-01

At iterate    5    f=  5.74872D+00    |proj g|=  5.08840D-02

At iterate   10    f=  5.72044D+00    |proj g|=  1.22272D-02
 This problem is unconstrained.
At iterate   15    f=  5.70277D+00    |proj g|=  5.62918D-02

At iterate   20    f=  5.69641D+00    |proj g|=  1.65135D-02

At iterate   25    f=  5.69106D+00    |proj g|=  2.43449D-01

At iterate   30    f=  5.68977D+00    |proj g|=  1.85250D-01

At iterate   35    f=  5.68879D+00    |proj g|=  1.66775D-01

At iterate   40    f=  5.68554D+00    |proj g|=  2.25321D-01

At iterate   45    f=  5.68265D+00    |proj g|=  1.42301D-01

At iterate   50    f=  5.68232D+00    |proj g|=  3.42101D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     69      1     0     0   3.421D-01   5.682D+00
  F =   5.6823247454131920     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.51640D+00    |proj g|=  1.01919D+00

At iterate    5    f=  6.43626D+00    |proj g|=  7.80768D-01
 This problem is unconstrained.
At iterate   10    f=  6.35393D+00    |proj g|=  7.58559D-02

At iterate   15    f=  6.28961D+00    |proj g|=  2.89482D-02

At iterate   20    f=  6.27408D+00    |proj g|=  1.00191D-01

At iterate   25    f=  6.25398D+00    |proj g|=  1.37962D-01

At iterate   30    f=  6.25227D+00    |proj g|=  6.21988D-03

At iterate   35    f=  6.25124D+00    |proj g|=  1.09445D-01

At iterate   40    f=  6.24843D+00    |proj g|=  5.00871D-02

At iterate   45    f=  6.24833D+00    |proj g|=  3.41618D-02

At iterate   50    f=  6.24819D+00    |proj g|=  9.72436D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     66      1     0     0   9.724D-02   6.248D+00
  F =   6.2481883557951798     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.25528D+00    |proj g|=  8.86577D-01

At iterate    5    f=  6.07642D+00    |proj g|=  4.02842D-02
 This problem is unconstrained.
At iterate   10    f=  6.05813D+00    |proj g|=  1.90330D-02

At iterate   15    f=  6.04652D+00    |proj g|=  5.28153D-02

At iterate   20    f=  6.03012D+00    |proj g|=  3.43404D-02

At iterate   25    f=  6.00416D+00    |proj g|=  3.06128D-02

At iterate   30    f=  5.98915D+00    |proj g|=  3.87431D-01

At iterate   35    f=  5.98295D+00    |proj g|=  3.19181D-01

At iterate   40    f=  5.98042D+00    |proj g|=  5.83605D-02

At iterate   45    f=  5.97749D+00    |proj g|=  4.75783D-01

At iterate   50    f=  5.97536D+00    |proj g|=  2.84525D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     65      1     0     0   2.845D-01   5.975D+00
  F =   5.9753602237261694     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.04743D+00    |proj g|=  1.82452D+00

At iterate    5    f=  6.63928D+00    |proj g|=  1.34542D-01
 This problem is unconstrained.
At iterate   10    f=  6.57685D+00    |proj g|=  4.32610D-02

At iterate   15    f=  6.54638D+00    |proj g|=  6.93714D-02

At iterate   20    f=  6.50313D+00    |proj g|=  5.13413D-01

At iterate   25    f=  6.48845D+00    |proj g|=  2.68817D-02

At iterate   30    f=  6.47111D+00    |proj g|=  1.19925D-01

At iterate   35    f=  6.46696D+00    |proj g|=  1.66781D-02

At iterate   40    f=  6.46671D+00    |proj g|=  6.02008D-03

At iterate   45    f=  6.46657D+00    |proj g|=  3.56772D-02

At iterate   50    f=  6.45043D+00    |proj g|=  2.97631D+00

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     76      1     0     0   2.976D+00   6.450D+00
  F =   6.4504286598181162     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.36841D+00    |proj g|=  5.30057D-01

At iterate    5    f=  6.25387D+00    |proj g|=  1.27177D-01
 This problem is unconstrained.
At iterate   10    f=  6.23019D+00    |proj g|=  3.02172D-02

At iterate   15    f=  6.21487D+00    |proj g|=  1.36354D-01

At iterate   20    f=  6.19219D+00    |proj g|=  2.95479D-02

At iterate   25    f=  6.19100D+00    |proj g|=  4.21504D-03

At iterate   30    f=  6.19082D+00    |proj g|=  8.29183D-03

At iterate   35    f=  6.17879D+00    |proj g|=  1.06393D-01

At iterate   40    f=  6.17211D+00    |proj g|=  1.86891D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     44     51      1     0     0   6.095D-05   6.172D+00
  F =   6.1721002942942764     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.95610D+00    |proj g|=  1.71836D+00

At iterate    5    f=  6.62099D+00    |proj g|=  2.37243D-01

At iterate   10    f=  6.53634D+00    |proj g|=  2.47976D-02
 This problem is unconstrained.
At iterate   15    f=  6.51190D+00    |proj g|=  2.19118D-01

At iterate   20    f=  6.47294D+00    |proj g|=  1.19962D-01

At iterate   25    f=  6.45899D+00    |proj g|=  9.63491D-02

At iterate   30    f=  6.44128D+00    |proj g|=  8.98669D-02

At iterate   35    f=  6.43984D+00    |proj g|=  1.17916D-01

At iterate   40    f=  6.43931D+00    |proj g|=  7.75376D-02

At iterate   45    f=  6.43892D+00    |proj g|=  4.25117D-02

At iterate   50    f=  6.43783D+00    |proj g|=  9.84231D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     71      1     0     0   9.842D-01   6.438D+00
  F =   6.4378330553196186     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  5.87573D+00    |proj g|=  2.92416D-01
 This problem is unconstrained.
At iterate    5    f=  5.83481D+00    |proj g|=  3.17479D-02

At iterate   10    f=  5.83283D+00    |proj g|=  7.46588D-03

At iterate   15    f=  5.82161D+00    |proj g|=  4.51274D-02

At iterate   20    f=  5.81415D+00    |proj g|=  2.90867D-02

At iterate   25    f=  5.80686D+00    |proj g|=  1.86880D-03

At iterate   30    f=  5.80669D+00    |proj g|=  6.83560D-03

At iterate   35    f=  5.80231D+00    |proj g|=  4.84046D-02

At iterate   40    f=  5.79912D+00    |proj g|=  1.91309D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     43     52      1     0     0   6.831D-06   5.799D+00
  F =   5.7991148974316493     

CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL            
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.60057D+00    |proj g|=  1.18440D+00

At iterate    5    f=  6.39698D+00    |proj g|=  2.23084D-01
 This problem is unconstrained.
At iterate   10    f=  6.35779D+00    |proj g|=  4.19745D-02

At iterate   15    f=  6.34797D+00    |proj g|=  3.96137D-02

At iterate   20    f=  6.33790D+00    |proj g|=  3.65507D-02

At iterate   25    f=  6.33750D+00    |proj g|=  4.71485D-03

At iterate   30    f=  6.33742D+00    |proj g|=  9.93302D-03

At iterate   35    f=  6.33526D+00    |proj g|=  1.27467D-01

At iterate   40    f=  6.33323D+00    |proj g|=  1.12350D-02

At iterate   45    f=  6.33259D+00    |proj g|=  9.55296D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     49     58      1     0     0   5.226D-05   6.333D+00
  F =   6.3325853239770717     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  8.28476D+00    |proj g|=  3.23137D+00
 This problem is unconstrained.
At iterate    5    f=  7.50921D+00    |proj g|=  1.05994D-01

At iterate   10    f=  7.37172D+00    |proj g|=  1.58511D-01

At iterate   15    f=  7.34441D+00    |proj g|=  4.54299D-01

At iterate   20    f=  7.34144D+00    |proj g|=  1.61723D-02

At iterate   25    f=  7.33720D+00    |proj g|=  2.30704D-01

At iterate   30    f=  7.33214D+00    |proj g|=  1.48882D-01

At iterate   35    f=  7.30857D+00    |proj g|=  6.06056D+00

At iterate   40    f=  7.28128D+00    |proj g|=  1.25229D+00

At iterate   45    f=  7.27940D+00    |proj g|=  6.08379D-01

At iterate   50    f=  7.27123D+00    |proj g|=  6.96977D+00

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     71      1     0     0   6.970D+00   7.271D+00
  F =   7.2712313749416984     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  5.85857D+00    |proj g|=  7.07147D-02
 This problem is unconstrained.
At iterate    5    f=  5.84370D+00    |proj g|=  1.10848D-01

At iterate   10    f=  5.81339D+00    |proj g|=  3.68114D-02

At iterate   15    f=  5.79486D+00    |proj g|=  1.18583D-01

At iterate   20    f=  5.79113D+00    |proj g|=  1.46206D-01

At iterate   25    f=  5.78533D+00    |proj g|=  3.69246D-02

At iterate   30    f=  5.78176D+00    |proj g|=  1.20486D-01

At iterate   35    f=  5.78113D+00    |proj g|=  2.09947D-02

At iterate   40    f=  5.78103D+00    |proj g|=  1.17892D-02

At iterate   45    f=  5.78102D+00    |proj g|=  1.53201D-03

At iterate   50    f=  5.78082D+00    |proj g|=  2.04546D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     62      1     0     0   2.045D-01   5.781D+00
  F =   5.7808209502092014     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.42504D+00    |proj g|=  5.22374D-01
 This problem is unconstrained.
At iterate    5    f=  6.34379D+00    |proj g|=  4.90552D-02

At iterate   10    f=  6.29658D+00    |proj g|=  1.43478D-01

At iterate   15    f=  6.24124D+00    |proj g|=  3.33527D-02

At iterate   20    f=  6.20620D+00    |proj g|=  2.12258D-02

At iterate   25    f=  6.19101D+00    |proj g|=  1.29448D-01

At iterate   30    f=  6.18629D+00    |proj g|=  8.08819D-02

At iterate   35    f=  6.18115D+00    |proj g|=  1.93269D-01

At iterate   40    f=  6.17271D+00    |proj g|=  8.87386D-02

At iterate   45    f=  6.17198D+00    |proj g|=  1.00193D-02

At iterate   50    f=  6.17197D+00    |proj g|=  2.06875D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     61      1     0     0   2.069D-02   6.172D+00
  F =   6.1719650213550352     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
 This problem is unconstrained.
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.48550D+00    |proj g|=  7.88760D-01

At iterate    5    f=  6.29413D+00    |proj g|=  1.00132D-01

At iterate   10    f=  6.26745D+00    |proj g|=  1.78237D-02

At iterate   15    f=  6.23039D+00    |proj g|=  1.96518D-02

At iterate   20    f=  6.22767D+00    |proj g|=  1.69481D-03

At iterate   25    f=  6.22374D+00    |proj g|=  1.81158D-02

At iterate   30    f=  6.21088D+00    |proj g|=  4.12920D-03

At iterate   35    f=  6.21084D+00    |proj g|=  5.48801D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     37     44      1     0     0   7.929D-06   6.211D+00
  F =   6.2108378849149330     

CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL            
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.27633D+00    |proj g|=  3.52012D-01
 This problem is unconstrained.
At iterate    5    f=  6.16913D+00    |proj g|=  1.44028D-01

At iterate   10    f=  6.14064D+00    |proj g|=  3.29725D-02

At iterate   15    f=  6.12884D+00    |proj g|=  1.70122D-02

At iterate   20    f=  6.12553D+00    |proj g|=  1.58616D-02

At iterate   25    f=  6.12263D+00    |proj g|=  2.95376D-03

At iterate   30    f=  6.12256D+00    |proj g|=  7.70754D-03

At iterate   35    f=  6.12011D+00    |proj g|=  5.43120D-02

At iterate   40    f=  6.10979D+00    |proj g|=  6.05850D-02

At iterate   45    f=  6.10935D+00    |proj g|=  5.16656D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     47     57      1     0     0   5.764D-05   6.109D+00
  F =   6.1093487455465647     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.11612D+00    |proj g|=  9.18914D-01
 This problem is unconstrained.
At iterate    5    f=  6.88613D+00    |proj g|=  8.80499D-02

At iterate   10    f=  6.85861D+00    |proj g|=  4.61984D-02

At iterate   15    f=  6.81101D+00    |proj g|=  1.43423D-01

At iterate   20    f=  6.78202D+00    |proj g|=  8.74276D-02

At iterate   25    f=  6.72455D+00    |proj g|=  4.78440D-02

At iterate   30    f=  6.70891D+00    |proj g|=  1.00605D-02

At iterate   35    f=  6.70387D+00    |proj g|=  2.25250D-02

At iterate   40    f=  6.70191D+00    |proj g|=  5.38670D-02

At iterate   45    f=  6.70168D+00    |proj g|=  3.03593D-02

At iterate   50    f=  6.70045D+00    |proj g|=  2.03945D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     70      1     0     0   2.039D-01   6.700D+00
  F =   6.7004536162522390     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.23006D+00    |proj g|=  2.38499D-01
 This problem is unconstrained.
At iterate    5    f=  6.19948D+00    |proj g|=  2.47572D-02

At iterate   10    f=  6.18519D+00    |proj g|=  6.05094D-02

At iterate   15    f=  6.15744D+00    |proj g|=  8.66196D-02

At iterate   20    f=  6.11667D+00    |proj g|=  2.96280D-02

At iterate   25    f=  6.10652D+00    |proj g|=  4.86860D-02

At iterate   30    f=  6.10184D+00    |proj g|=  2.14021D-02

At iterate   35    f=  6.10163D+00    |proj g|=  1.80991D-02

At iterate   40    f=  6.09385D+00    |proj g|=  1.40460D-01

At iterate   45    f=  6.08928D+00    |proj g|=  3.19893D-02

At iterate   50    f=  6.08912D+00    |proj g|=  2.16148D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     62      1     0     0   2.161D-03   6.089D+00
  F =   6.0891178909476222     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.15415D+00    |proj g|=  6.35333D-01
 This problem is unconstrained.
At iterate    5    f=  6.01693D+00    |proj g|=  3.95940D-02

At iterate   10    f=  6.01541D+00    |proj g|=  1.05098D-02

At iterate   15    f=  6.01171D+00    |proj g|=  1.16787D-01

At iterate   20    f=  5.98408D+00    |proj g|=  3.59924D-02

At iterate   25    f=  5.94813D+00    |proj g|=  5.42663D-01

At iterate   30    f=  5.92607D+00    |proj g|=  3.86784D-02

At iterate   35    f=  5.90200D+00    |proj g|=  8.13767D-02

At iterate   40    f=  5.89801D+00    |proj g|=  6.63775D-02

At iterate   45    f=  5.88651D+00    |proj g|=  1.61635D-01

At iterate   50    f=  5.87902D+00    |proj g|=  4.73640D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     74      1     0     0   4.736D-01   5.879D+00
  F =   5.8790248278325308     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
In [ ]:
# Make an average forecast for store IDs in the test dataset that are not in the training dataset
test_store_forecasts = average_forecast_for_test_stores(models, test_data,'daily_yoy_ndt.total_food_service')

# if test_store_forecasts is not None:
#     for store_id, forecast in zip(set(test_data['site_id_msba'].unique()) - set(models.keys()), test_store_forecasts):
#         print(f'Average Forecast for Store {store_id}:\n{forecast}')
# else:
#     print('No matching models found in the training data for the new test data store IDs.')
In [ ]:
# Plot the actual vs predicted values of Food Service Sales for each stores in test set
if test_store_forecasts is not None:
    for store_id, forecast in zip(set(test_data['site_id_msba'].unique()) - set(models.keys()), test_store_forecasts):
        store_data = test_data[test_data['site_id_msba'] == store_id]
        actual_data = store_data['daily_yoy_ndt.total_food_service']
        time_index = range(1, len(actual_data) + 1)
        plt.figure(figsize=(10, 6))
        plt.plot(time_index, actual_data, label='Actual', linestyle='-', color='blue')
        plt.plot(time_index, forecast, label='Predicted', linestyle='-', color='red')
        plt.title(f'Actual vs. Predicted Food Sales for Store {store_id}')
        plt.xlabel('Time Period')
        plt.ylabel('Sales')
        plt.legend()
        plt.grid(True)
        plt.show()
In [ ]:
# Evaluate the prediction error metrics for Food service Sales
results = {}
if test_store_forecasts is not None:
    for store_id, forecast in zip(set(test_data['site_id_msba'].unique()) - set(models.keys()), test_store_forecasts):
        store_data = test_data[test_data['site_id_msba'] == store_id]
        actual_data = store_data['daily_yoy_ndt.total_food_service']
        # Calculate the Mean Squared Error (MSE) for the predictions
        mse = mean_squared_error(actual_data, forecast)

        # Calculate the Root Mean Squared Error (RMSE)
        rmse = math.sqrt(mse)

        # Store the results in the dictionary
        results['daily_yoy_ndt.total_food_service'] = {
            'Predictions': forecast,
            'MSE': mse,
            'RMSE': rmse
        }

        print(f"RMSE of Food Service sales for Store {store_id}: {rmse}")
        print('\n')
RMSE of Food Service sales for Store 24535: 270.78717975170576


Diesel

In [ ]:
# Train ARIMA models for each store in traindf
models = train_arima_models(train_data,'diesel_y')
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.64542D+00    |proj g|=  1.30362D-01

At iterate    5    f=  7.54154D+00    |proj g|=  1.81940D-01

At iterate   10    f=  7.51212D+00    |proj g|=  1.29890D-01
 This problem is unconstrained.
At iterate   15    f=  7.49724D+00    |proj g|=  2.64113D-02

At iterate   20    f=  7.48878D+00    |proj g|=  2.40491D-02

At iterate   25    f=  7.48835D+00    |proj g|=  5.20925D-04

At iterate   30    f=  7.48829D+00    |proj g|=  7.37192D-03

At iterate   35    f=  7.48599D+00    |proj g|=  2.81633D-02

At iterate   40    f=  7.47210D+00    |proj g|=  6.51090D-02

At iterate   45    f=  7.46762D+00    |proj g|=  4.43045D-03

At iterate   50    f=  7.46759D+00    |proj g|=  4.43958D-05

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     57      1     0     0   4.440D-05   7.468D+00
  F =   7.4675895752448360     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.97465D+00    |proj g|=  6.92183D-01
 This problem is unconstrained.
At iterate    5    f=  7.84324D+00    |proj g|=  1.03699D-01

At iterate   10    f=  7.77905D+00    |proj g|=  6.74755D-02

At iterate   15    f=  7.72129D+00    |proj g|=  1.30709D-01

At iterate   20    f=  7.70088D+00    |proj g|=  6.85364D-02

At iterate   25    f=  7.67578D+00    |proj g|=  1.07751D-01

At iterate   30    f=  7.66757D+00    |proj g|=  3.44835D-02

At iterate   35    f=  7.66638D+00    |proj g|=  3.38014D-01

At iterate   40    f=  7.66339D+00    |proj g|=  1.15437D-01

At iterate   45    f=  7.66180D+00    |proj g|=  5.86932D-02

At iterate   50    f=  7.66111D+00    |proj g|=  9.31305D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     78      1     0     0   9.313D-02   7.661D+00
  F =   7.6611058903170619     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  8.40081D+00    |proj g|=  2.70579D+00
 This problem is unconstrained.
At iterate    5    f=  7.82431D+00    |proj g|=  2.16546D-01

At iterate   10    f=  7.76853D+00    |proj g|=  1.49283D-02

At iterate   15    f=  7.75795D+00    |proj g|=  1.82228D-01

At iterate   20    f=  7.70199D+00    |proj g|=  2.56105D-01

At iterate   25    f=  7.69483D+00    |proj g|=  1.96665D-01

At iterate   30    f=  7.68840D+00    |proj g|=  2.56560D-02

At iterate   35    f=  7.68242D+00    |proj g|=  3.96552D-01

At iterate   40    f=  7.67931D+00    |proj g|=  3.27749D-01

At iterate   45    f=  7.67272D+00    |proj g|=  3.84448D-01

At iterate   50    f=  7.67041D+00    |proj g|=  1.19599D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     68      1     0     0   1.196D-01   7.670D+00
  F =   7.6704099675284017     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  8.12125D+00    |proj g|=  8.73654D-01
 This problem is unconstrained.
At iterate    5    f=  7.99896D+00    |proj g|=  2.39708D-01

At iterate   10    f=  7.90590D+00    |proj g|=  1.41356D-02

At iterate   15    f=  7.90131D+00    |proj g|=  6.99417D-02

At iterate   20    f=  7.82783D+00    |proj g|=  8.79099D-02

At iterate   25    f=  7.78617D+00    |proj g|=  3.22177D-01

At iterate   30    f=  7.77098D+00    |proj g|=  1.26302D-01

At iterate   35    f=  7.76749D+00    |proj g|=  9.79797D-02

At iterate   40    f=  7.76674D+00    |proj g|=  2.46842D-02

At iterate   45    f=  7.76657D+00    |proj g|=  4.95244D-02

At iterate   50    f=  7.76651D+00    |proj g|=  2.71681D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     61      1     0     0   2.717D-02   7.767D+00
  F =   7.7665057961896879     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
 This problem is unconstrained.
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  9.42311D+00    |proj g|=  2.56256D+00

At iterate    5    f=  8.82351D+00    |proj g|=  1.49654D-01

At iterate   10    f=  8.75704D+00    |proj g|=  4.87824D-02

At iterate   15    f=  8.74190D+00    |proj g|=  4.41012D-01

At iterate   20    f=  8.69165D+00    |proj g|=  2.09707D-01

At iterate   25    f=  8.66811D+00    |proj g|=  3.38167D-01

At iterate   30    f=  8.65153D+00    |proj g|=  4.81886D-01

At iterate   35    f=  8.64634D+00    |proj g|=  1.55476D-01

At iterate   40    f=  8.63759D+00    |proj g|=  4.50285D-02

At iterate   45    f=  8.63701D+00    |proj g|=  3.48372D-02

At iterate   50    f=  8.63620D+00    |proj g|=  1.21536D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     74      1     0     0   1.215D-01   8.636D+00
  F =   8.6361967355833507     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  9.18462D+00    |proj g|=  2.19681D+00

At iterate    5    f=  8.12541D+00    |proj g|=  4.71675D-01
 This problem is unconstrained.
At iterate   10    f=  8.06506D+00    |proj g|=  1.56885D-01

At iterate   15    f=  8.00528D+00    |proj g|=  1.05608D-01

At iterate   20    f=  7.98757D+00    |proj g|=  3.03341D-01

At iterate   25    f=  7.98493D+00    |proj g|=  3.03987D-02

At iterate   30    f=  7.98489D+00    |proj g|=  2.38204D-02

At iterate   35    f=  7.98371D+00    |proj g|=  1.27190D-01

At iterate   40    f=  7.98259D+00    |proj g|=  2.27259D-02

At iterate   45    f=  7.98254D+00    |proj g|=  4.45505D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     46     54      1     0     0   3.283D-04   7.983D+00
  F =   7.9825351649367855     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  5.93853D+00    |proj g|=  2.61290D-01
 This problem is unconstrained.
At iterate    5    f=  5.88094D+00    |proj g|=  1.34225D-01

At iterate   10    f=  5.86946D+00    |proj g|=  2.33615D-01

At iterate   15    f=  5.84083D+00    |proj g|=  8.41214D-02

At iterate   20    f=  5.83458D+00    |proj g|=  2.37199D-02

At iterate   25    f=  5.83296D+00    |proj g|=  2.20352D-02

At iterate   30    f=  5.83009D+00    |proj g|=  7.38200D-02

At iterate   35    f=  5.82513D+00    |proj g|=  3.17558D-02

At iterate   40    f=  5.82207D+00    |proj g|=  1.90858D-01

At iterate   45    f=  5.82006D+00    |proj g|=  1.93761D-01

At iterate   50    f=  5.81910D+00    |proj g|=  6.32415D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     75      1     0     0   6.324D-02   5.819D+00
  F =   5.8191046884385536     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.60446D+00    |proj g|=  1.91597D-01
 This problem is unconstrained.
At iterate    5    f=  6.56081D+00    |proj g|=  2.60179D-02

At iterate   10    f=  6.53726D+00    |proj g|=  2.00868D-01

At iterate   15    f=  6.52406D+00    |proj g|=  5.19364D-02

At iterate   20    f=  6.52034D+00    |proj g|=  1.44391D-01

At iterate   25    f=  6.51744D+00    |proj g|=  5.45463D-02

At iterate   30    f=  6.51286D+00    |proj g|=  1.65365D-01

At iterate   35    f=  6.50909D+00    |proj g|=  9.86378D-01

At iterate   40    f=  6.50794D+00    |proj g|=  1.41087D-01

At iterate   45    f=  6.50679D+00    |proj g|=  7.11277D-01

At iterate   50    f=  6.50579D+00    |proj g|=  1.88608D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     62      1     0     0   1.886D-01   6.506D+00
  F =   6.5057905214985610     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  5.50296D+00    |proj g|=  3.21889D-02

At iterate    5    f=  5.49912D+00    |proj g|=  2.15119D-02

At iterate   10    f=  5.49633D+00    |proj g|=  1.83216D-03

At iterate   15    f=  5.49467D+00    |proj g|=  1.24609D-02
 This problem is unconstrained.
At iterate   20    f=  5.49421D+00    |proj g|=  9.24573D-04

At iterate   25    f=  5.49399D+00    |proj g|=  2.00407D-03

At iterate   30    f=  5.49369D+00    |proj g|=  1.79937D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     34     37      1     0     0   1.439D-05   5.494D+00
  F =   5.4936848728995971     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.09918D+00    |proj g|=  4.76783D-02
 This problem is unconstrained.
At iterate    5    f=  6.07911D+00    |proj g|=  7.71431D-03

At iterate   10    f=  6.05924D+00    |proj g|=  1.97561D-02

At iterate   15    f=  6.05587D+00    |proj g|=  1.55639D-02

At iterate   20    f=  6.03542D+00    |proj g|=  1.29551D-01

At iterate   25    f=  6.02450D+00    |proj g|=  4.78165D-02

At iterate   30    f=  6.02419D+00    |proj g|=  3.36557D-03

At iterate   35    f=  6.02407D+00    |proj g|=  5.34562D-02

At iterate   40    f=  6.02364D+00    |proj g|=  4.91510D-02

At iterate   45    f=  6.01915D+00    |proj g|=  1.93278D-01

At iterate   50    f=  6.01566D+00    |proj g|=  3.92156D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     72      1     0     0   3.922D-01   6.016D+00
  F =   6.0156586953786180     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  5.54025D+00    |proj g|=  4.65159D-01
 This problem is unconstrained.
At iterate    5    f=  5.51989D+00    |proj g|=  2.26721D-01

At iterate   10    f=  5.50698D+00    |proj g|=  1.50633D-02

At iterate   15    f=  5.50150D+00    |proj g|=  1.84571D-02

At iterate   20    f=  5.48976D+00    |proj g|=  1.23615D-01

At iterate   25    f=  5.48535D+00    |proj g|=  1.38360D-01

At iterate   30    f=  5.48266D+00    |proj g|=  2.38293D-01

At iterate   35    f=  5.47823D+00    |proj g|=  4.06985D-01

At iterate   40    f=  5.47765D+00    |proj g|=  3.41194D-02

At iterate   45    f=  5.47623D+00    |proj g|=  5.31598D-01

At iterate   50    f=  5.47459D+00    |proj g|=  3.39820D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     64      1     0     0   3.398D-01   5.475D+00
  F =   5.4745923169619131     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  5.75904D+00    |proj g|=  1.51192D-01
 This problem is unconstrained.
At iterate    5    f=  5.74428D+00    |proj g|=  1.82418D-02

At iterate   10    f=  5.74113D+00    |proj g|=  1.69433D-02

At iterate   15    f=  5.72723D+00    |proj g|=  7.15254D-02

At iterate   20    f=  5.72059D+00    |proj g|=  5.03556D-02

At iterate   25    f=  5.71932D+00    |proj g|=  8.26327D-02

At iterate   30    f=  5.71742D+00    |proj g|=  2.01623D-01

At iterate   35    f=  5.71368D+00    |proj g|=  3.27375D-02

At iterate   40    f=  5.71365D+00    |proj g|=  1.34034D-03

At iterate   45    f=  5.71360D+00    |proj g|=  2.81401D-02

At iterate   50    f=  5.71358D+00    |proj g|=  6.43712D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     64      1     0     0   6.437D-03   5.714D+00
  F =   5.7135789959309591     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.52780D+00    |proj g|=  8.38190D-02

At iterate    5    f=  7.52327D+00    |proj g|=  2.65266D-02

At iterate   10    f=  7.51229D+00    |proj g|=  2.56116D-02

At iterate   15    f=  7.50419D+00    |proj g|=  2.58885D-02
 This problem is unconstrained.
At iterate   20    f=  7.49582D+00    |proj g|=  8.03129D-02

At iterate   25    f=  7.48506D+00    |proj g|=  3.69210D-02

At iterate   30    f=  7.48274D+00    |proj g|=  2.19767D-02

At iterate   35    f=  7.48271D+00    |proj g|=  1.02319D-02

At iterate   40    f=  7.48242D+00    |proj g|=  4.57390D-03

At iterate   45    f=  7.48242D+00    |proj g|=  3.71633D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     45     50      1     0     0   3.716D-04   7.482D+00
  F =   7.4824163351460085     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.55642D+00    |proj g|=  2.01212D-01

At iterate    5    f=  7.46670D+00    |proj g|=  1.57817D-02

At iterate   10    f=  7.46444D+00    |proj g|=  1.33398D-03

At iterate   15    f=  7.46406D+00    |proj g|=  1.95828D-02
 This problem is unconstrained.
At iterate   20    f=  7.43177D+00    |proj g|=  1.56866D-01

At iterate   25    f=  7.39771D+00    |proj g|=  7.68173D-02

At iterate   30    f=  7.37825D+00    |proj g|=  2.89469D-01

At iterate   35    f=  7.37033D+00    |proj g|=  1.41973D-01

At iterate   40    f=  7.36711D+00    |proj g|=  2.19349D-01

At iterate   45    f=  7.36551D+00    |proj g|=  1.18310D-01

At iterate   50    f=  7.36535D+00    |proj g|=  3.37625D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     67      1     0     0   3.376D-02   7.365D+00
  F =   7.3653524424049719     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.15655D+00    |proj g|=  4.50203D-02

At iterate    5    f=  6.15100D+00    |proj g|=  1.55581D-02
 This problem is unconstrained.
At iterate   10    f=  6.14836D+00    |proj g|=  8.77051D-04

At iterate   15    f=  6.14831D+00    |proj g|=  7.25220D-04

At iterate   20    f=  6.14744D+00    |proj g|=  9.49606D-03

At iterate   25    f=  6.14698D+00    |proj g|=  4.82304D-03

At iterate   30    f=  6.14664D+00    |proj g|=  1.42428D-03

At iterate   35    f=  6.14660D+00    |proj g|=  8.21226D-04

At iterate   40    f=  6.14656D+00    |proj g|=  3.27646D-03

At iterate   45    f=  6.14626D+00    |proj g|=  3.12896D-03

At iterate   50    f=  6.14602D+00    |proj g|=  1.03155D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     61      1     0     0   1.032D-02   6.146D+00
  F =   6.1460201420008049     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  8.12377D+00    |proj g|=  1.81633D+00

At iterate    5    f=  7.86134D+00    |proj g|=  5.80155D-01
 This problem is unconstrained.
At iterate   10    f=  7.72330D+00    |proj g|=  1.41710D-01

At iterate   15    f=  7.69117D+00    |proj g|=  2.02943D-01

At iterate   20    f=  7.64991D+00    |proj g|=  1.81547D-01

At iterate   25    f=  7.63754D+00    |proj g|=  1.48084D-01

At iterate   30    f=  7.62841D+00    |proj g|=  6.55878D-01

At iterate   35    f=  7.62425D+00    |proj g|=  8.42873D-02

At iterate   40    f=  7.62279D+00    |proj g|=  1.95430D-01

At iterate   45    f=  7.62171D+00    |proj g|=  8.68865D-02

At iterate   50    f=  7.62087D+00    |proj g|=  5.95342D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     55      1     0     0   5.953D-02   7.621D+00
  F =   7.6208670879699527     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.29238D+00    |proj g|=  1.24486D-01
 This problem is unconstrained.
At iterate    5    f=  6.22147D+00    |proj g|=  1.66199D-02

At iterate   10    f=  6.21749D+00    |proj g|=  1.13582D-02

At iterate   15    f=  6.21665D+00    |proj g|=  5.11430D-04

At iterate   20    f=  6.21662D+00    |proj g|=  1.88381D-03

At iterate   25    f=  6.21623D+00    |proj g|=  5.92743D-03

At iterate   30    f=  6.21555D+00    |proj g|=  1.00279D-03

At iterate   35    f=  6.21554D+00    |proj g|=  3.31811D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     36     42      1     0     0   8.480D-06   6.216D+00
  F =   6.2155413369592445     

CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL            
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.16144D+00    |proj g|=  1.60067D+00

At iterate    5    f=  6.89899D+00    |proj g|=  2.39696D-01
 This problem is unconstrained.
At iterate   10    f=  6.71065D+00    |proj g|=  4.46547D-02

At iterate   15    f=  6.66302D+00    |proj g|=  3.44697D-02

At iterate   20    f=  6.63498D+00    |proj g|=  8.23903D-02

At iterate   25    f=  6.62918D+00    |proj g|=  5.85838D-02

At iterate   30    f=  6.62833D+00    |proj g|=  1.55843D-02

At iterate   35    f=  6.62061D+00    |proj g|=  1.88734D-01

At iterate   40    f=  6.61644D+00    |proj g|=  1.40637D-01

At iterate   45    f=  6.61407D+00    |proj g|=  1.57774D-01

At iterate   50    f=  6.61309D+00    |proj g|=  7.37059D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     70      1     0     0   7.371D-02   6.613D+00
  F =   6.6130870833445501     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
 This problem is unconstrained.
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.55021D+00    |proj g|=  5.99659D-01

At iterate    5    f=  7.46647D+00    |proj g|=  1.48936D-01

At iterate   10    f=  7.42731D+00    |proj g|=  1.46607D-01

At iterate   15    f=  7.35684D+00    |proj g|=  1.12645D-01

At iterate   20    f=  7.33123D+00    |proj g|=  4.82980D-02

At iterate   25    f=  7.28965D+00    |proj g|=  9.59031D-02

At iterate   30    f=  7.28293D+00    |proj g|=  7.73467D-02

At iterate   35    f=  7.27290D+00    |proj g|=  3.21200D-02

At iterate   40    f=  7.26958D+00    |proj g|=  1.52712D-01

At iterate   45    f=  7.26943D+00    |proj g|=  9.40767D-04

At iterate   50    f=  7.26939D+00    |proj g|=  8.59336D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     62      1     0     0   8.593D-03   7.269D+00
  F =   7.2693859142936397     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  8.39344D+00    |proj g|=  2.84198D+00

At iterate    5    f=  7.83955D+00    |proj g|=  1.11843D-01
 This problem is unconstrained.
At iterate   10    f=  7.74123D+00    |proj g|=  5.60398D-02

At iterate   15    f=  7.71808D+00    |proj g|=  2.05772D-02

At iterate   20    f=  7.70903D+00    |proj g|=  1.86579D-01

At iterate   25    f=  7.68907D+00    |proj g|=  1.39537D-01

At iterate   30    f=  7.68079D+00    |proj g|=  6.39356D-02

At iterate   35    f=  7.67834D+00    |proj g|=  1.42134D-01

At iterate   40    f=  7.67726D+00    |proj g|=  1.54479D-01

At iterate   45    f=  7.67679D+00    |proj g|=  1.56549D-01

At iterate   50    f=  7.67630D+00    |proj g|=  2.23071D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     65      1     0     0   2.231D-02   7.676D+00
  F =   7.6763045596244348     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  5.70887D+00    |proj g|=  3.38292D-01
 This problem is unconstrained.
At iterate    5    f=  5.47377D+00    |proj g|=  1.79972D-02

At iterate   10    f=  5.46732D+00    |proj g|=  2.24477D-02

At iterate   15    f=  5.46291D+00    |proj g|=  2.40746D-02

At iterate   20    f=  5.46058D+00    |proj g|=  1.08634D-01

At iterate   25    f=  5.45248D+00    |proj g|=  1.81587D-01

At iterate   30    f=  5.44620D+00    |proj g|=  7.76906D-02

At iterate   35    f=  5.44303D+00    |proj g|=  3.85952D-02

At iterate   40    f=  5.44209D+00    |proj g|=  1.32996D-01

At iterate   45    f=  5.43784D+00    |proj g|=  1.16905D-01

At iterate   50    f=  5.43646D+00    |proj g|=  1.50959D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     90      1     0     0   1.510D-01   5.436D+00
  F =   5.4364621510927673     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  9.89692D+00    |proj g|=  1.14784D+01

At iterate    5    f=  8.01709D+00    |proj g|=  3.39822D-01

At iterate   10    f=  7.87365D+00    |proj g|=  2.04691D-01

At iterate   15    f=  7.83491D+00    |proj g|=  3.31033D-02
 This problem is unconstrained.
At iterate   20    f=  7.82311D+00    |proj g|=  1.21924D-01

At iterate   25    f=  7.81751D+00    |proj g|=  1.02974D-01

At iterate   30    f=  7.81626D+00    |proj g|=  5.95549D-02

At iterate   35    f=  7.80783D+00    |proj g|=  2.37020D-01

At iterate   40    f=  7.80751D+00    |proj g|=  1.95704D-02

At iterate   45    f=  7.80743D+00    |proj g|=  7.10746D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     48     58      1     0     0   4.277D-04   7.807D+00
  F =   7.8074320517654767     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

 This problem is unconstrained.
Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  8.56620D+00    |proj g|=  1.00718D+00

At iterate    5    f=  8.33170D+00    |proj g|=  1.12347D-01

At iterate   10    f=  8.28664D+00    |proj g|=  1.25535D-01

At iterate   15    f=  8.24963D+00    |proj g|=  1.18947D-02

At iterate   20    f=  8.24751D+00    |proj g|=  4.91900D-04

At iterate   25    f=  8.24750D+00    |proj g|=  1.31622D-03

At iterate   30    f=  8.24706D+00    |proj g|=  1.96719D-02

At iterate   35    f=  8.23641D+00    |proj g|=  3.16003D-02

At iterate   40    f=  8.23308D+00    |proj g|=  1.37243D-02

At iterate   45    f=  8.23060D+00    |proj g|=  4.03213D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     47     51      1     0     0   1.865D-05   8.231D+00
  F =   8.2306027509069182     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
 This problem is unconstrained.
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.88903D+00    |proj g|=  4.91001D-01

At iterate    5    f=  7.73848D+00    |proj g|=  6.28606D-02

At iterate   10    f=  7.70067D+00    |proj g|=  1.61278D-01

At iterate   15    f=  7.61636D+00    |proj g|=  8.99268D-02

At iterate   20    f=  7.52355D+00    |proj g|=  1.94069D-01

At iterate   25    f=  7.50756D+00    |proj g|=  5.90142D-02

At iterate   30    f=  7.49895D+00    |proj g|=  1.01898D-01

At iterate   35    f=  7.49856D+00    |proj g|=  9.00968D-02

At iterate   40    f=  7.49574D+00    |proj g|=  8.53780D-01

At iterate   45    f=  7.49302D+00    |proj g|=  1.75858D-01

At iterate   50    f=  7.49236D+00    |proj g|=  4.81553D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     61      1     0     0   4.816D-02   7.492D+00
  F =   7.4923559307897953     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.52882D+00    |proj g|=  7.13847D-01

At iterate    5    f=  7.43110D+00    |proj g|=  1.77025D-01
 This problem is unconstrained.
At iterate   10    f=  7.37337D+00    |proj g|=  9.90826D-02

At iterate   15    f=  7.25181D+00    |proj g|=  1.40739D-01

At iterate   20    f=  7.22498D+00    |proj g|=  2.34044D-02

At iterate   25    f=  7.22289D+00    |proj g|=  1.85965D-02

At iterate   30    f=  7.21748D+00    |proj g|=  5.94271D-01

At iterate   35    f=  7.21530D+00    |proj g|=  1.66200D-01

At iterate   40    f=  7.21373D+00    |proj g|=  1.47254D-01

At iterate   45    f=  7.21174D+00    |proj g|=  5.56791D-01

At iterate   50    f=  7.20960D+00    |proj g|=  2.52622D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     66      1     0     0   2.526D-01   7.210D+00
  F =   7.2096042384127879     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  5.86840D+00    |proj g|=  3.70329D-01
 This problem is unconstrained.
At iterate    5    f=  5.80609D+00    |proj g|=  1.39731D-01

At iterate   10    f=  5.78300D+00    |proj g|=  8.07736D-02

At iterate   15    f=  5.77127D+00    |proj g|=  9.32353D-02

At iterate   20    f=  5.76839D+00    |proj g|=  2.12851D-02

At iterate   25    f=  5.76804D+00    |proj g|=  7.38523D-03

At iterate   30    f=  5.76326D+00    |proj g|=  1.73887D-02

At iterate   35    f=  5.76299D+00    |proj g|=  3.30869D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     39     45      1     0     0   6.151D-05   5.763D+00
  F =   5.7629917991590274     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
 This problem is unconstrained.
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  5.58933D+00    |proj g|=  1.75987D-01

At iterate    5    f=  5.56834D+00    |proj g|=  4.05660D-02

At iterate   10    f=  5.56661D+00    |proj g|=  1.44532D-02

At iterate   15    f=  5.55946D+00    |proj g|=  8.85651D-02

At iterate   20    f=  5.55722D+00    |proj g|=  8.06819D-03

At iterate   25    f=  5.55565D+00    |proj g|=  1.71087D-02

At iterate   30    f=  5.55510D+00    |proj g|=  3.40557D-03

At iterate   35    f=  5.55506D+00    |proj g|=  4.65420D-03

At iterate   40    f=  5.55412D+00    |proj g|=  5.85532D-02

At iterate   45    f=  5.55234D+00    |proj g|=  1.03260D-03

At iterate   50    f=  5.55234D+00    |proj g|=  3.38612D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     59      1     0     0   3.386D-04   5.552D+00
  F =   5.5523356910057799     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
 This problem is unconstrained.
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  9.00625D+00    |proj g|=  1.85768D+00

At iterate    5    f=  8.58758D+00    |proj g|=  1.90317D-01

At iterate   10    f=  8.48839D+00    |proj g|=  5.25087D-02

At iterate   15    f=  8.43961D+00    |proj g|=  9.31873D-02

At iterate   20    f=  8.39666D+00    |proj g|=  1.82564D-01

At iterate   25    f=  8.37571D+00    |proj g|=  7.86927D-01

At iterate   30    f=  8.36934D+00    |proj g|=  6.19444D-02

At iterate   35    f=  8.36672D+00    |proj g|=  1.54201D-01

At iterate   40    f=  8.36574D+00    |proj g|=  7.53178D-02

At iterate   45    f=  8.36381D+00    |proj g|=  8.67885D-02

At iterate   50    f=  8.36363D+00    |proj g|=  1.12213D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     64      1     0     0   1.122D-02   8.364D+00
  F =   8.3636251674292499     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.65399D+00    |proj g|=  1.84718D+00

At iterate    5    f=  7.62808D+00    |proj g|=  1.37581D-01

At iterate   10    f=  7.62561D+00    |proj g|=  1.27057D-02
 This problem is unconstrained.
At iterate   15    f=  7.62420D+00    |proj g|=  1.48600D-01

At iterate   20    f=  7.62376D+00    |proj g|=  8.61925D-03

At iterate   25    f=  7.62236D+00    |proj g|=  2.03779D-02

At iterate   30    f=  7.62121D+00    |proj g|=  1.13310D-02

At iterate   35    f=  7.62099D+00    |proj g|=  4.03397D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     37     44      1     0     0   3.012D-03   7.621D+00
  F =   7.6209915692931443     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.70543D+00    |proj g|=  9.88263D-02
 This problem is unconstrained.
At iterate    5    f=  6.70304D+00    |proj g|=  3.89285D-02

At iterate   10    f=  6.68899D+00    |proj g|=  7.11062D-02

At iterate   15    f=  6.67700D+00    |proj g|=  5.10762D-02

At iterate   20    f=  6.67683D+00    |proj g|=  1.90481D-02

At iterate   25    f=  6.67597D+00    |proj g|=  1.38267D-02

At iterate   30    f=  6.67570D+00    |proj g|=  1.61785D-03

At iterate   35    f=  6.67570D+00    |proj g|=  3.64253D-03

At iterate   40    f=  6.67567D+00    |proj g|=  1.24615D-02

At iterate   45    f=  6.67507D+00    |proj g|=  1.54308D-02

At iterate   50    f=  6.67447D+00    |proj g|=  8.00926D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     61      1     0     0   8.009D-04   6.674D+00
  F =   6.6744719095032412     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
In [ ]:
# Make an average forecast for store IDs in the test dataset that are not in the training dataset
test_store_forecasts = average_forecast_for_test_stores(models, test_data,'diesel_y')

# if test_store_forecasts is not None:
#     for store_id, forecast in zip(set(test_data['site_id_msba'].unique()) - set(models.keys()), test_store_forecasts):
#         print(f'Average Forecast for Store {store_id}:\n{forecast}')
# else:
#     print('No matching models found in the training data for the new test data store IDs.')
In [ ]:
# Plot the actual vs predicted values of Diesel Sales for each stores in test set
if test_store_forecasts is not None:
    for store_id, forecast in zip(set(test_data['site_id_msba'].unique()) - set(models.keys()), test_store_forecasts):
        store_data = test_data[test_data['site_id_msba'] == store_id]
        actual_data = store_data['diesel_y']
        time_index = range(1, len(actual_data) + 1)
        plt.figure(figsize=(10, 6))
        plt.plot(time_index, actual_data, label='Actual', linestyle='-', color='blue')
        plt.plot(time_index, forecast, label='Predicted', linestyle='-', color='red')
        plt.title(f'Actual vs. Predicted Diesel Sales for Store {store_id}')
        plt.xlabel('Time Period')
        plt.ylabel('Sales')
        plt.legend()
        plt.grid(True)
        plt.show()
In [ ]:
# Evaluate the prediction error metrics for Diesel Sales
results = {}
if test_store_forecasts is not None:
    for store_id, forecast in zip(set(test_data['site_id_msba'].unique()) - set(models.keys()), test_store_forecasts):
        store_data = test_data[test_data['site_id_msba'] == store_id]
        actual_data = store_data['diesel_y']
        # Calculate the Mean Squared Error (MSE) for the predictions
        mse = mean_squared_error(actual_data, forecast)

        # Calculate the Root Mean Squared Error (RMSE)
        rmse = math.sqrt(mse)

        # Store the results in the dictionary
        results['diesel_y'] = {
            'Predictions': forecast,
            'MSE': mse,
            'RMSE': rmse
        }

        print(f"RMSE of Diesel sales for Store {store_id}: {rmse}")
        print('\n')
RMSE of Diesel sales for Store 24535: 660.7248288187691


Unleaded

In [ ]:
# Train ARIMA models for each store in traindf
models = train_arima_models(train_data,'unleaded')
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.23567D+00    |proj g|=  1.78464D-01
 This problem is unconstrained.
At iterate    5    f=  7.20472D+00    |proj g|=  4.27163D-02

At iterate   10    f=  7.19353D+00    |proj g|=  3.03462D-02

At iterate   15    f=  7.18192D+00    |proj g|=  1.98092D-02

At iterate   20    f=  7.17656D+00    |proj g|=  5.57540D-02

At iterate   25    f=  7.17022D+00    |proj g|=  1.28378D-01

At iterate   30    f=  7.16853D+00    |proj g|=  6.60515D-02

At iterate   35    f=  7.16834D+00    |proj g|=  3.24634D-03

At iterate   40    f=  7.16804D+00    |proj g|=  3.41608D-02

At iterate   45    f=  7.16702D+00    |proj g|=  1.16063D-02

At iterate   50    f=  7.16698D+00    |proj g|=  1.67009D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     61      1     0     0   1.670D-03   7.167D+00
  F =   7.1669835505156367     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.84553D+00    |proj g|=  9.72926D-01
 This problem is unconstrained.
At iterate    5    f=  7.58917D+00    |proj g|=  8.01225D-02

At iterate   10    f=  7.56061D+00    |proj g|=  9.09169D-02

At iterate   15    f=  7.52695D+00    |proj g|=  1.57565D-02

At iterate   20    f=  7.51416D+00    |proj g|=  1.41279D-01

At iterate   25    f=  7.47659D+00    |proj g|=  1.40019D-01

At iterate   30    f=  7.45279D+00    |proj g|=  1.35757D-01

At iterate   35    f=  7.44453D+00    |proj g|=  3.76038D-01

At iterate   40    f=  7.43473D+00    |proj g|=  7.74475D-01

At iterate   45    f=  7.43265D+00    |proj g|=  2.33334D-01

At iterate   50    f=  7.43059D+00    |proj g|=  9.31050D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     69      1     0     0   9.310D-02   7.431D+00
  F =   7.4305888401359992     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.23350D+00    |proj g|=  2.33543D-01
 This problem is unconstrained.
At iterate    5    f=  7.10646D+00    |proj g|=  2.57353D-02

At iterate   10    f=  7.08593D+00    |proj g|=  3.80283D-02

At iterate   15    f=  7.07898D+00    |proj g|=  2.21775D-02

At iterate   20    f=  7.07816D+00    |proj g|=  1.56524D-03

At iterate   25    f=  7.07814D+00    |proj g|=  7.78915D-03

At iterate   30    f=  7.07307D+00    |proj g|=  7.71993D-02

At iterate   35    f=  7.06637D+00    |proj g|=  1.41398D-02

At iterate   40    f=  7.06634D+00    |proj g|=  9.10632D-05

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     42     51      1     0     0   1.420D-05   7.066D+00
  F =   7.0663419851136986     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.19254D+00    |proj g|=  4.08440D-01
 This problem is unconstrained.
At iterate    5    f=  7.09191D+00    |proj g|=  5.00102D-02

At iterate   10    f=  7.08563D+00    |proj g|=  2.72629D-03

At iterate   15    f=  7.07519D+00    |proj g|=  9.83891D-02

At iterate   20    f=  7.06549D+00    |proj g|=  1.76929D-02

At iterate   25    f=  7.06293D+00    |proj g|=  1.71133D-03

At iterate   30    f=  7.06293D+00    |proj g|=  7.01685D-04

At iterate   35    f=  7.06280D+00    |proj g|=  9.10163D-03

At iterate   40    f=  7.06176D+00    |proj g|=  6.91505D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     44     55      1     0     0   4.258D-05   7.062D+00
  F =   7.0617086724483382     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.38422D+00    |proj g|=  3.92135D-01

At iterate    5    f=  7.33853D+00    |proj g|=  1.04383D-01
 This problem is unconstrained.
At iterate   10    f=  7.31996D+00    |proj g|=  3.71640D-02

At iterate   15    f=  7.31843D+00    |proj g|=  3.75513D-02

At iterate   20    f=  7.31074D+00    |proj g|=  4.63397D-01

At iterate   25    f=  7.30531D+00    |proj g|=  3.72668D-02

At iterate   30    f=  7.30408D+00    |proj g|=  9.33891D-01

At iterate   35    f=  7.30305D+00    |proj g|=  8.36571D-02

At iterate   40    f=  7.30234D+00    |proj g|=  1.25575D-01

At iterate   45    f=  7.30156D+00    |proj g|=  1.74095D-01

At iterate   50    f=  7.30104D+00    |proj g|=  3.21639D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     71      1     0     0   3.216D-01   7.301D+00
  F =   7.3010408172727166     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.07417D+00    |proj g|=  2.05849D-01

At iterate    5    f=  7.02596D+00    |proj g|=  9.60359D-02
 This problem is unconstrained.
At iterate   10    f=  6.98731D+00    |proj g|=  4.09833D-02

At iterate   15    f=  6.94520D+00    |proj g|=  3.68910D-02

At iterate   20    f=  6.93007D+00    |proj g|=  2.78610D-02

At iterate   25    f=  6.92986D+00    |proj g|=  1.91977D-02

At iterate   30    f=  6.92732D+00    |proj g|=  8.71427D-02

At iterate   35    f=  6.92681D+00    |proj g|=  3.58577D-03

At iterate   40    f=  6.92679D+00    |proj g|=  1.11420D-02

At iterate   45    f=  6.92679D+00    |proj g|=  5.52180D-03

At iterate   50    f=  6.92666D+00    |proj g|=  8.66222D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     59      1     0     0   8.662D-03   6.927D+00
  F =   6.9266564929857655     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
 This problem is unconstrained.
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.88044D+00    |proj g|=  8.27869D-01

At iterate    5    f=  6.73235D+00    |proj g|=  1.31726D-01

At iterate   10    f=  6.69302D+00    |proj g|=  7.82917D-02

At iterate   15    f=  6.68660D+00    |proj g|=  1.16501D-02

At iterate   20    f=  6.68491D+00    |proj g|=  1.15897D-03

At iterate   25    f=  6.68474D+00    |proj g|=  6.12834D-03

At iterate   30    f=  6.67170D+00    |proj g|=  1.55542D-01

At iterate   35    f=  6.66811D+00    |proj g|=  9.09598D-03

At iterate   40    f=  6.66524D+00    |proj g|=  2.52711D-02

At iterate   45    f=  6.66447D+00    |proj g|=  4.47954D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     47     55      1     0     0   1.529D-05   6.664D+00
  F =   6.6644707389972488     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.27835D+00    |proj g|=  1.31844D-01
 This problem is unconstrained.
At iterate    5    f=  7.25199D+00    |proj g|=  2.44713D-02

At iterate   10    f=  7.24055D+00    |proj g|=  7.75142D-02

At iterate   15    f=  7.23462D+00    |proj g|=  3.98060D-02

At iterate   20    f=  7.23079D+00    |proj g|=  1.07024D-01

At iterate   25    f=  7.22534D+00    |proj g|=  2.01419D-02

At iterate   30    f=  7.22280D+00    |proj g|=  5.06194D-02

At iterate   35    f=  7.22060D+00    |proj g|=  1.83849D-01

At iterate   40    f=  7.21901D+00    |proj g|=  2.01801D-01

At iterate   45    f=  7.21884D+00    |proj g|=  3.50452D-03

At iterate   50    f=  7.21883D+00    |proj g|=  1.61660D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     59      1     0     0   1.617D-02   7.219D+00
  F =   7.2188319172191946     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.08613D+00    |proj g|=  8.54973D-01
 This problem is unconstrained.
At iterate    5    f=  7.05419D+00    |proj g|=  7.85589D-02

At iterate   10    f=  7.04736D+00    |proj g|=  2.61832D-02

At iterate   15    f=  7.00300D+00    |proj g|=  1.26522D-02

At iterate   20    f=  6.99481D+00    |proj g|=  2.48172D-01

At iterate   25    f=  6.97591D+00    |proj g|=  1.79587D-02

At iterate   30    f=  6.96687D+00    |proj g|=  5.59756D-02

At iterate   35    f=  6.95916D+00    |proj g|=  3.72086D-02

At iterate   40    f=  6.95072D+00    |proj g|=  1.60413D-02

At iterate   45    f=  6.94915D+00    |proj g|=  2.20294D-02

At iterate   50    f=  6.94848D+00    |proj g|=  4.78147D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     64      1     0     0   4.781D-02   6.948D+00
  F =   6.9484802711585401     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.31590D+00    |proj g|=  5.10437D-01

At iterate    5    f=  7.22322D+00    |proj g|=  5.76394D-02

 This problem is unconstrained.
At iterate   10    f=  7.21835D+00    |proj g|=  1.52326D-02

At iterate   15    f=  7.20863D+00    |proj g|=  3.73717D-02

At iterate   20    f=  7.20596D+00    |proj g|=  2.68747D-03

At iterate   25    f=  7.20590D+00    |proj g|=  1.13321D-03

At iterate   30    f=  7.20333D+00    |proj g|=  2.30415D-02

At iterate   35    f=  7.19974D+00    |proj g|=  2.41955D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     39     54      1     0     0   9.022D-06   7.200D+00
  F =   7.1997391224645142     

CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL            
 This problem is unconstrained.
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.90080D+00    |proj g|=  1.99156D-01

At iterate    5    f=  6.85851D+00    |proj g|=  3.99148D-02

At iterate   10    f=  6.84484D+00    |proj g|=  3.99258D-02

At iterate   15    f=  6.83799D+00    |proj g|=  3.95416D-02

At iterate   20    f=  6.83692D+00    |proj g|=  1.07091D-02

At iterate   25    f=  6.83686D+00    |proj g|=  1.37064D-03

At iterate   30    f=  6.83664D+00    |proj g|=  1.07538D-02

At iterate   35    f=  6.82987D+00    |proj g|=  2.49962D-02

At iterate   40    f=  6.82964D+00    |proj g|=  1.72170D-05

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     40     45      1     0     0   1.722D-05   6.830D+00
  F =   6.8296364300779473     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.72285D+00    |proj g|=  3.14506D-02
 This problem is unconstrained.
At iterate    5    f=  7.71724D+00    |proj g|=  1.35667D-02

At iterate   10    f=  7.71602D+00    |proj g|=  2.97367D-03

At iterate   15    f=  7.71524D+00    |proj g|=  4.71559D-03

At iterate   20    f=  7.71522D+00    |proj g|=  1.81005D-04

At iterate   25    f=  7.71522D+00    |proj g|=  2.35151D-05
 Warning:  more than 10 function and gradient
   evaluations in the last line search.  Termination
   may possibly be caused by a bad search direction.
 This problem is unconstrained.
           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     26     44      1     0     0   2.352D-05   7.715D+00
  F =   7.7152190704587680     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.50249D+00    |proj g|=  8.02874D-02

At iterate    5    f=  7.48387D+00    |proj g|=  4.12144D-02

At iterate   10    f=  7.48244D+00    |proj g|=  1.05595D-02

At iterate   15    f=  7.47812D+00    |proj g|=  3.83717D-02

At iterate   20    f=  7.47161D+00    |proj g|=  1.10739D-01

At iterate   25    f=  7.46980D+00    |proj g|=  2.27159D-02

At iterate   30    f=  7.46970D+00    |proj g|=  1.97669D-03

At iterate   35    f=  7.46954D+00    |proj g|=  1.01439D-03

At iterate   40    f=  7.46954D+00    |proj g|=  3.20485D-03

At iterate   45    f=  7.46916D+00    |proj g|=  2.52029D-02

At iterate   50    f=  7.46613D+00    |proj g|=  1.52555D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     60      1     0     0   1.526D-02   7.466D+00
  F =   7.4661307276286868     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.81954D+00    |proj g|=  5.04842D-01
 This problem is unconstrained.
At iterate    5    f=  7.70584D+00    |proj g|=  7.87757D-02

At iterate   10    f=  7.70156D+00    |proj g|=  1.25455D-03

At iterate   15    f=  7.69218D+00    |proj g|=  8.02619D-02

At iterate   20    f=  7.68141D+00    |proj g|=  9.31703D-03

At iterate   25    f=  7.68098D+00    |proj g|=  2.10562D-04

At iterate   30    f=  7.68098D+00    |proj g|=  8.96776D-04

At iterate   35    f=  7.68036D+00    |proj g|=  7.02739D-03

At iterate   40    f=  7.67837D+00    |proj g|=  3.09252D-03

At iterate   45    f=  7.67836D+00    |proj g|=  7.19948D-05

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     47     56      1     0     0   2.120D-05   7.678D+00
  F =   7.6783555670115957     

CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH             
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  8.04258D+00    |proj g|=  6.67615D-02

At iterate    5    f=  8.00753D+00    |proj g|=  7.05193D-02

At iterate   10    f=  7.99723D+00    |proj g|=  1.27640D-03
 This problem is unconstrained.
At iterate   15    f=  7.99661D+00    |proj g|=  4.10145D-03

At iterate   20    f=  7.99651D+00    |proj g|=  2.62448D-04

At iterate   25    f=  7.99650D+00    |proj g|=  3.73255D-04

At iterate   30    f=  7.99643D+00    |proj g|=  6.83196D-03

At iterate   35    f=  7.99558D+00    |proj g|=  1.76467D-03

At iterate   40    f=  7.99554D+00    |proj g|=  4.95331D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     42     49      1     0     0   5.155D-06   7.996D+00
  F =   7.9955416428034027     

CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL            
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.69625D+00    |proj g|=  7.69951D-01
 This problem is unconstrained.
At iterate    5    f=  7.35133D+00    |proj g|=  1.73600D-01

At iterate   10    f=  7.32956D+00    |proj g|=  1.98360D-01

At iterate   15    f=  7.32127D+00    |proj g|=  8.18145D-03

At iterate   20    f=  7.31921D+00    |proj g|=  1.47414D-01

At iterate   25    f=  7.29799D+00    |proj g|=  7.66693D-01

At iterate   30    f=  7.29619D+00    |proj g|=  1.79793D-01

At iterate   35    f=  7.29609D+00    |proj g|=  6.76250D-03

At iterate   40    f=  7.29598D+00    |proj g|=  8.75580D-02

At iterate   45    f=  7.29534D+00    |proj g|=  1.92369D-02

At iterate   50    f=  7.29528D+00    |proj g|=  2.21510D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     57      1     0     0   2.215D-02   7.295D+00
  F =   7.2952778893672763     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.40176D+00    |proj g|=  6.34799D-02

At iterate    5    f=  7.39246D+00    |proj g|=  1.49434D-02

At iterate   10    f=  7.38254D+00    |proj g|=  3.71431D-02
 This problem is unconstrained.
At iterate   15    f=  7.37172D+00    |proj g|=  5.86042D-03

At iterate   20    f=  7.37161D+00    |proj g|=  1.16080D-04

At iterate   25    f=  7.37159D+00    |proj g|=  2.69333D-03

At iterate   30    f=  7.37111D+00    |proj g|=  7.05138D-03

At iterate   35    f=  7.37105D+00    |proj g|=  5.92390D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     38     44      1     0     0   2.815D-06   7.371D+00
  F =   7.3710491371599849     

CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL            
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.19410D+00    |proj g|=  7.33372D-01
 This problem is unconstrained.
At iterate    5    f=  6.96020D+00    |proj g|=  2.39129D-01

At iterate   10    f=  6.93639D+00    |proj g|=  9.01356D-02

At iterate   15    f=  6.93217D+00    |proj g|=  1.03215D-02

At iterate   20    f=  6.93095D+00    |proj g|=  1.61800D-02

At iterate   25    f=  6.93066D+00    |proj g|=  2.09581D-02

At iterate   30    f=  6.91952D+00    |proj g|=  1.99460D-01

At iterate   35    f=  6.91265D+00    |proj g|=  1.31121D-02

At iterate   40    f=  6.91237D+00    |proj g|=  3.51254D-03

At iterate   45    f=  6.91237D+00    |proj g|=  6.53690D-06

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     45     60      1     0     0   6.537D-06   6.912D+00
  F =   6.9123724402361626     

CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL            
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.17408D+00    |proj g|=  5.57398D-01

At iterate    5    f=  7.03518D+00    |proj g|=  7.40523D-02
 This problem is unconstrained.
At iterate   10    f=  7.02937D+00    |proj g|=  1.37596D-02

At iterate   15    f=  7.01844D+00    |proj g|=  7.67406D-02

At iterate   20    f=  7.01270D+00    |proj g|=  1.19322D-02

At iterate   25    f=  7.01260D+00    |proj g|=  4.78326D-04

At iterate   30    f=  7.01254D+00    |proj g|=  6.49688D-03

At iterate   35    f=  7.00823D+00    |proj g|=  1.23469D-02

At iterate   40    f=  7.00718D+00    |proj g|=  7.21887D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     44     50      1     0     0   4.142D-06   7.007D+00
  F =   7.0071665515383081     

CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_<=_PGTOL            
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.53452D+00    |proj g|=  7.31918D-01
 This problem is unconstrained.
At iterate    5    f=  7.44616D+00    |proj g|=  8.62384D-02

At iterate   10    f=  7.42823D+00    |proj g|=  1.93411D-02

At iterate   15    f=  7.41505D+00    |proj g|=  2.04486D-01

At iterate   20    f=  7.41177D+00    |proj g|=  2.29821D-02

At iterate   25    f=  7.41144D+00    |proj g|=  1.21926D-02

At iterate   30    f=  7.41137D+00    |proj g|=  3.67751D-03

At iterate   35    f=  7.41137D+00    |proj g|=  1.28508D-03

At iterate   40    f=  7.41132D+00    |proj g|=  2.44723D-02

At iterate   45    f=  7.40918D+00    |proj g|=  1.82647D-01

At iterate   50    f=  7.40431D+00    |proj g|=  1.27158D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     60      1     0     0   1.272D-02   7.404D+00
  F =   7.4043079252549981     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.49422D+00    |proj g|=  2.72444D-01

At iterate    5    f=  6.41478D+00    |proj g|=  7.98419D-02

 This problem is unconstrained.
At iterate   10    f=  6.39329D+00    |proj g|=  6.80256D-02

At iterate   15    f=  6.38613D+00    |proj g|=  4.13778D-02

At iterate   20    f=  6.38094D+00    |proj g|=  1.70815D-01

At iterate   25    f=  6.37648D+00    |proj g|=  9.05649D-03

At iterate   30    f=  6.37611D+00    |proj g|=  1.35238D-02

At iterate   35    f=  6.37501D+00    |proj g|=  5.48411D-02

At iterate   40    f=  6.37486D+00    |proj g|=  5.91094D-03

At iterate   45    f=  6.37467D+00    |proj g|=  4.94772D-02

At iterate   50    f=  6.37006D+00    |proj g|=  2.05068D-01

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     59      1     0     0   2.051D-01   6.370D+00
  F =   6.3700581874343341     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.80150D+00    |proj g|=  4.43340D-01
 This problem is unconstrained.
At iterate    5    f=  7.64677D+00    |proj g|=  4.63723D-02

At iterate   10    f=  7.61727D+00    |proj g|=  5.40755D-01

At iterate   15    f=  7.58131D+00    |proj g|=  3.11254D-02

At iterate   20    f=  7.56948D+00    |proj g|=  2.95401D-01

At iterate   25    f=  7.56881D+00    |proj g|=  5.75073D-02

At iterate   30    f=  7.56744D+00    |proj g|=  2.77644D-02

At iterate   35    f=  7.56467D+00    |proj g|=  9.47549D-02

At iterate   40    f=  7.56453D+00    |proj g|=  6.03034D-04

At iterate   45    f=  7.56453D+00    |proj g|=  2.81896D-03

At iterate   50    f=  7.56442D+00    |proj g|=  3.02320D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     59      1     0     0   3.023D-02   7.564D+00
  F =   7.5644232079450511     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  8.09564D+00    |proj g|=  1.64051D+00
 This problem is unconstrained.
At iterate    5    f=  7.85538D+00    |proj g|=  4.31455D-01

At iterate   10    f=  7.62685D+00    |proj g|=  1.22726D-01

At iterate   15    f=  7.57243D+00    |proj g|=  1.65369D-01

At iterate   20    f=  7.52974D+00    |proj g|=  6.36302D-02

At iterate   25    f=  7.50485D+00    |proj g|=  3.50901D-02

At iterate   30    f=  7.50178D+00    |proj g|=  2.93054D-01

At iterate   35    f=  7.50024D+00    |proj g|=  4.21027D-02

At iterate   40    f=  7.49925D+00    |proj g|=  1.09838D-01

At iterate   45    f=  7.49861D+00    |proj g|=  8.43174D-02

At iterate   50    f=  7.49841D+00    |proj g|=  1.49017D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     63      1     0     0   1.490D-02   7.498D+00
  F =   7.4984085338965185     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.34824D+00    |proj g|=  2.28874D-01
 This problem is unconstrained.
At iterate    5    f=  7.27220D+00    |proj g|=  5.54807D-02

At iterate   10    f=  7.23633D+00    |proj g|=  6.20710D-02

At iterate   15    f=  7.21503D+00    |proj g|=  2.16165D-01

At iterate   20    f=  7.21021D+00    |proj g|=  9.27258D-02

At iterate   25    f=  7.20683D+00    |proj g|=  2.87621D-01

At iterate   30    f=  7.20306D+00    |proj g|=  4.25823D-02

At iterate   35    f=  7.20129D+00    |proj g|=  4.62627D-02

At iterate   40    f=  7.20115D+00    |proj g|=  4.36552D-03

At iterate   45    f=  7.20113D+00    |proj g|=  8.80248D-03

At iterate   50    f=  7.20113D+00    |proj g|=  2.51239D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     55      1     0     0   2.512D-03   7.201D+00
  F =   7.2011267946257007     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.38165D+00    |proj g|=  5.78115D-01
 This problem is unconstrained.
At iterate    5    f=  7.29160D+00    |proj g|=  3.65442D-01

At iterate   10    f=  7.24733D+00    |proj g|=  8.80826D-02

At iterate   15    f=  7.23111D+00    |proj g|=  5.58372D-02

At iterate   20    f=  7.22912D+00    |proj g|=  4.35479D-03

At iterate   25    f=  7.22905D+00    |proj g|=  9.44793D-04

At iterate   30    f=  7.22899D+00    |proj g|=  2.72448D-03

At iterate   35    f=  7.22610D+00    |proj g|=  2.91406D-01

At iterate   40    f=  7.21556D+00    |proj g|=  1.10581D-02

At iterate   45    f=  7.21538D+00    |proj g|=  2.16839D-02

At iterate   50    f=  7.21534D+00    |proj g|=  3.07188D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     59      1     0     0   3.072D-04   7.215D+00
  F =   7.2153362483559400     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
 This problem is unconstrained.
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.10450D+00    |proj g|=  3.51269D-01

At iterate    5    f=  7.07042D+00    |proj g|=  8.43591D-02

At iterate   10    f=  7.06544D+00    |proj g|=  1.47357D-02

At iterate   15    f=  7.05120D+00    |proj g|=  3.20717D-01

At iterate   20    f=  7.04420D+00    |proj g|=  2.91092D-02

At iterate   25    f=  7.04409D+00    |proj g|=  5.86692D-03

At iterate   30    f=  7.04393D+00    |proj g|=  4.01037D-04

At iterate   35    f=  7.04393D+00    |proj g|=  3.52304D-03

At iterate   40    f=  7.04366D+00    |proj g|=  1.87910D-02

At iterate   45    f=  7.03784D+00    |proj g|=  3.35492D-01

At iterate   50    f=  7.03437D+00    |proj g|=  1.83992D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     66      1     0     0   1.840D-02   7.034D+00
  F =   7.0343743748350755     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  6.63494D+00    |proj g|=  2.47624D-01

At iterate    5    f=  6.56754D+00    |proj g|=  8.58774D-02
 This problem is unconstrained.
At iterate   10    f=  6.53573D+00    |proj g|=  3.76692D-01

At iterate   15    f=  6.52011D+00    |proj g|=  4.12678D-02

At iterate   20    f=  6.51521D+00    |proj g|=  2.73343D-02

At iterate   25    f=  6.51499D+00    |proj g|=  1.35859D-02

At iterate   30    f=  6.51490D+00    |proj g|=  5.88635D-03

At iterate   35    f=  6.51452D+00    |proj g|=  8.55319D-03

At iterate   40    f=  6.51449D+00    |proj g|=  6.67633D-03

At iterate   45    f=  6.51435D+00    |proj g|=  5.05835D-02

At iterate   50    f=  6.50200D+00    |proj g|=  3.58212D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     60      1     0     0   3.582D-02   6.502D+00
  F =   6.5019990433054433     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.60902D+00    |proj g|=  4.91714D-01
 This problem is unconstrained.
At iterate    5    f=  7.47461D+00    |proj g|=  8.87324D-02

At iterate   10    f=  7.45585D+00    |proj g|=  1.35666D-02

At iterate   15    f=  7.44489D+00    |proj g|=  4.01060D-02

At iterate   20    f=  7.42874D+00    |proj g|=  8.33092D-02

At iterate   25    f=  7.42554D+00    |proj g|=  6.39757D-03

At iterate   30    f=  7.42539D+00    |proj g|=  1.12934D-03

At iterate   35    f=  7.42539D+00    |proj g|=  1.72564D-03

At iterate   40    f=  7.42506D+00    |proj g|=  2.86858D-02

At iterate   45    f=  7.41576D+00    |proj g|=  4.20082D-02

At iterate   50    f=  7.41390D+00    |proj g|=  1.22830D-04

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     58      1     0     0   1.228D-04   7.414D+00
  F =   7.4139011573832718     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.29425D+00    |proj g|=  4.95185D-01

At iterate    5    f=  7.18090D+00    |proj g|=  3.46695D-02

At iterate   10    f=  7.13819D+00    |proj g|=  4.26003D-02
 This problem is unconstrained.
At iterate   15    f=  7.10774D+00    |proj g|=  6.41760D-02

At iterate   20    f=  7.09781D+00    |proj g|=  7.72213D-02

At iterate   25    f=  7.09603D+00    |proj g|=  2.98949D-02

At iterate   30    f=  7.09334D+00    |proj g|=  1.79123D-03

At iterate   35    f=  7.09329D+00    |proj g|=  2.39111D-03

At iterate   40    f=  7.09093D+00    |proj g|=  6.37829D-02

At iterate   45    f=  7.08234D+00    |proj g|=  3.03567D-01

At iterate   50    f=  7.07882D+00    |proj g|=  4.23592D-03

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     64      1     0     0   4.236D-03   7.079D+00
  F =   7.0788226001457222     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
RUNNING THE L-BFGS-B CODE

           * * *

Machine precision = 2.220D-16
 N =            6     M =           10

At X0         0 variables are exactly at the bounds

At iterate    0    f=  7.53418D+00    |proj g|=  5.44815D-01

At iterate    5    f=  7.41227D+00    |proj g|=  9.77167D-02
 This problem is unconstrained.
At iterate   10    f=  7.39097D+00    |proj g|=  3.84830D-02

At iterate   15    f=  7.37298D+00    |proj g|=  7.56477D-02

At iterate   20    f=  7.36829D+00    |proj g|=  2.91480D-02

At iterate   25    f=  7.36605D+00    |proj g|=  5.69951D-03

At iterate   30    f=  7.36597D+00    |proj g|=  4.43235D-04

At iterate   35    f=  7.36595D+00    |proj g|=  2.51104D-02

At iterate   40    f=  7.36385D+00    |proj g|=  2.41653D-01

At iterate   45    f=  7.35756D+00    |proj g|=  3.05368D-02

At iterate   50    f=  7.35601D+00    |proj g|=  2.50901D-02

           * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized Cauchy point
Projg = norm of the final projected gradient
F     = final function value

           * * *

   N    Tit     Tnf  Tnint  Skip  Nact     Projg        F
    6     50     61      1     0     0   2.509D-02   7.356D+00
  F =   7.3560097127321962     

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT                 
In [ ]:
# Make an average forecast for store IDs in the test dataset that are not in the training dataset
test_store_forecasts = average_forecast_for_test_stores(models, test_data,'unleaded')

# if test_store_forecasts is not None:
#     for store_id, forecast in zip(set(test_data['site_id_msba'].unique()) - set(models.keys()), test_store_forecasts):
#         print(f'Average Forecast for Store {store_id}:\n{forecast}')
# else:
#     print('No matching models found in the training data for the new test data store IDs.')
In [ ]:
# Plot the actual vs predicted values of Unleaded Sales for each stores in test set
if test_store_forecasts is not None:
    for store_id, forecast in zip(set(test_data['site_id_msba'].unique()) - set(models.keys()), test_store_forecasts):
        store_data = test_data[test_data['site_id_msba'] == store_id]
        actual_data = store_data['unleaded']
        time_index = range(1, len(actual_data) + 1)
        plt.figure(figsize=(10, 6))
        plt.plot(time_index, actual_data, label='Actual', linestyle='-', color='blue')
        plt.plot(time_index, forecast, label='Predicted', linestyle='-', color='red')
        plt.title(f'Actual vs. Predicted Unleaded Sales for Store {store_id}')
        plt.xlabel('Time Period')
        plt.ylabel('Sales')
        plt.legend()
        plt.grid(True)
        plt.show()
In [ ]:
# Evaluate the prediction error metrics for Unleaded Sales
results = {}
if test_store_forecasts is not None:
    for store_id, forecast in zip(set(test_data['site_id_msba'].unique()) - set(models.keys()), test_store_forecasts):
        store_data = test_data[test_data['site_id_msba'] == store_id]
        actual_data = store_data['unleaded']
        # Calculate the Mean Squared Error (MSE) for the predictions
        mse = mean_squared_error(actual_data, forecast)

        # Calculate the Root Mean Squared Error (RMSE)
        rmse = math.sqrt(mse)

        # Store the results in the dictionary
        results['unleaded'] = {
            'Predictions': forecast,
            'MSE': mse,
            'RMSE': rmse
        }

        print(f"RMSE of Unleaded sales for Store {store_id}: {rmse}")
        print('\n')
RMSE of Unleaded sales for Store 24535: 809.3692592057246


Prophet

Prophet is a forecasting tool developed by Meta designed to make predictions for time series data with strong seasonal patterns and missing data points.

This model captures weekly and holiday seasonality for each sales metric and uses feature selection to capture strongly correlated variables to improve model performance.

Each sales metric section shows RMSE and MAE for test stores.

Training and Testing the model doesn't take much time, less than five minutes.

Running the cross-validation for the Prophet models takes forty minutes.

In [ ]:
# Splitting by Train and Test for Prophet
np.random.seed(1234)
# First, determine which stores to include in the training and testing sets
unique_stores = df_prophet_copy['store_id'].unique()  # Ensure this contains all unique stores
# You could shuffle this array if you want a random selection of stores for train/test
np.random.shuffle(unique_stores)  # Only if random selection is desired

# Select stores for training and testing
train_stores = unique_stores[6:]
test_stores = unique_stores[:6]
print(test_stores.tolist())
# Define a function to split the data for each metric for Prophet
def split_data(prophet_df):
    train_data = prophet_df[prophet_df['store_id'].isin(train_stores)]
    test_data = prophet_df[prophet_df['store_id'].isin(test_stores)]
    return train_data, test_data
# Split by Train and Test for each metric for Prophet
train_unleaded, test_unleaded = split_data(prophet_df_unleaded)
train_diesel, test_diesel = split_data(prophet_df_diesel)
train_food_sales, test_food_sales = split_data(prophet_df_food_sales)
train_inside_sales, test_inside_sales = split_data(prophet_df_inside_sales)
[22540, 24535, 22750, 22015, 22260, 23905]
In [ ]:
# Training the model

from prophet import Prophet

# Models dictionary
models = {}

# Define the list of extra regressors you want to add.
extra_regressors = [
    # 'x1_mile_pop', 'x1_mile_emp', 'x1_mile_income', 'x1_2_mile_pop', 'x1_2_mile_emp', 'x1_2_mile_income', 'x5_min_pop', 'x7_min_inc',
    'hi_flow_lanes_fueling_positions', 'mens_urinal_count', 'mens_toilet_count', 'womens_sink_count','x5_min_emp', 'x7_min_pop', 'x7_min_emp', 'open_year'
    ,'pizza_No', 'pizza_Yes', 'rv_lanes_No', 'rv_lanes_Yes', 'def_No', 'def_Yes', 'rv_lanes_layout_In-Line', 'rv_lanes_layout_None', 'rv_lanes_layout_Stack',
    'hi_flow_lanes_No', 'hi_flow_lanes_Yes', 'hi_flow_rv_lanes_No', 'hi_flow_rv_lanes_Yes'
    ]

# Train models for each metric
for metric in ['unleaded', 'diesel', 'food_sales', 'inside_sales']:
    # Initialize the Prophet model with holidays
    model = Prophet(holidays=holidays_df)
    # Add each extra regressor to the model
    for regressor in extra_regressors:
        model.add_regressor(regressor)
    # Select the training data for the current metric
    train_data = globals()[f'train_{metric}']
    # Fit the model using both the 'ds', 'y', and the extra regressors
    model.fit(train_data[['ds', 'y'] + extra_regressors])
    # Store the model in the dictionary
    models[metric] = model
21:30:06 - cmdstanpy - INFO - Chain [1] start processing
21:30:10 - cmdstanpy - INFO - Chain [1] done processing
21:30:17 - cmdstanpy - INFO - Chain [1] start processing
21:30:27 - cmdstanpy - INFO - Chain [1] done processing
21:30:32 - cmdstanpy - INFO - Chain [1] start processing
21:30:37 - cmdstanpy - INFO - Chain [1] done processing
21:30:52 - cmdstanpy - INFO - Chain [1] start processing
21:31:00 - cmdstanpy - INFO - Chain [1] done processing
In [ ]:
# Forecasting for Test Stores
# Dictionary to store forecasts
forecasts = {}

# Forecast for each metric and each store
for store_id in test_stores:
    for metric in ['unleaded', 'diesel', 'food_sales', 'inside_sales']:
        model = models[metric]
        # Select test data for the current store and metric
        test_data = globals()[f'test_{metric}']
        store_test_data = test_data[test_data['store_id'] == store_id]
        # Make sure that your future dataframe includes the regressor values
        # This assumes that the test data includes the same extra regressor columns as the training data
        future_regressors = store_test_data[extra_regressors].reset_index(drop=True)
        # Make future dataframe for the model
        future = model.make_future_dataframe(periods=len(store_test_data))
        future = future.merge(store_test_data[['ds']], on='ds', how='right')
        # Add the regressors to the future dataframe
        future = pd.concat([future, future_regressors], axis=1)
        # Forecast
        forecast = model.predict(future)
        # Store forecast with store ID and metric
        forecasts[(store_id, metric)] = forecast[['ds', 'yhat']]
In [ ]:
# Creating Evaluation Metrics
from sklearn.metrics import mean_squared_error, mean_absolute_error
from math import sqrt

# Evaluation metrics dictionary
evaluation_metrics = {}

# Calculate RMSE and MAE for each store and each metric
for store_id in test_stores:
    for metric in ['unleaded', 'diesel', 'food_sales', 'inside_sales']:
        # Actual sales
        actual = globals()[f'test_{metric}'][globals()[f'test_{metric}']['store_id'] == store_id]['y']
        # Predicted sales
        predicted = forecasts[(store_id, metric)]['yhat']
        # Ensure the lengths of actual and predicted are the same
        min_length = min(len(actual), len(predicted))
        actual, predicted = actual.iloc[:min_length], predicted.iloc[:min_length]
        # Calculate RMSE and MAE
        rmse = sqrt(mean_squared_error(actual, predicted))
        mae = mean_absolute_error(actual, predicted)
        # Store in dictionary
        evaluation_metrics[(store_id, metric)] = {'RMSE': rmse, 'MAE': mae}

# Custom sort order
metric_order = {'inside_sales': 1, 'food_sales': 2, 'diesel': 3, 'unleaded': 4}

# Sorting function that uses the metric_order for sorting
def custom_metric_sort(store_metric):
    _, metric = store_metric
    return metric_order[metric]

# Sort the evaluation_metrics keys based on the custom metric order
sorted_metrics = sorted(evaluation_metrics.keys(), key=custom_metric_sort)

# Function to print the metrics for a given type
def print_metrics_for_type(metric_type):
    for store_metric in sorted_metrics:
        store_id, metric = store_metric
        if metric == metric_type:
            metrics = evaluation_metrics[store_metric]
            print(f'Store ID: {store_id} - Metric: {metric}\n\tRMSE: {metrics["RMSE"]:.2f}\n\tMAE: {metrics["MAE"]:.2f}\n')

def plot_actual_vs_predicted(actual, predicted, metric, store_id):
    plt.figure(figsize=(10, 5))
    plt.plot(actual.reset_index(drop=True), label='Actual')
    plt.plot(predicted.reset_index(drop=True), label='Predicted', alpha=0.7)
    plt.title(f'Actual vs Predicted - {metric.capitalize()} for Store {store_id}')
    plt.xlabel('Time')
    plt.ylabel(metric.capitalize())
    plt.legend()
    plt.show()
Inside Sales

In [ ]:
# WITH REGRESSORS
# Organized review of metrics by type
print("Inside Sales Metrics:")
print_metrics_for_type('inside_sales')
Inside Sales Metrics:
Store ID: 22540 - Metric: inside_sales
	RMSE: 753.42
	MAE: 589.84

Store ID: 24535 - Metric: inside_sales
	RMSE: 692.53
	MAE: 545.59

Store ID: 22750 - Metric: inside_sales
	RMSE: 1436.67
	MAE: 1244.44

Store ID: 22015 - Metric: inside_sales
	RMSE: 803.90
	MAE: 641.56

Store ID: 22260 - Metric: inside_sales
	RMSE: 712.81
	MAE: 572.30

Store ID: 23905 - Metric: inside_sales
	RMSE: 604.98
	MAE: 473.59

In [ ]:
# Plot actual vs. predicted for 'inside_sales' for each store
for store_id in test_stores:
    metric = 'inside_sales'
    actual = globals()[f'test_{metric}'][globals()[f'test_{metric}']['store_id'] == store_id]['y']
    predicted = forecasts[(store_id, metric)]['yhat']
    min_length = min(len(actual), len(predicted))
    actual, predicted = actual.iloc[:min_length], predicted.iloc[:min_length]
    plot_actual_vs_predicted(actual, predicted, metric, store_id)
Food Service

In [ ]:
# WITH REGRESSORS
print("Food Sales Metrics:")
print_metrics_for_type('food_sales')
Food Sales Metrics:
Store ID: 22540 - Metric: food_sales
	RMSE: 282.59
	MAE: 224.13

Store ID: 24535 - Metric: food_sales
	RMSE: 253.43
	MAE: 203.64

Store ID: 22750 - Metric: food_sales
	RMSE: 423.89
	MAE: 374.53

Store ID: 22015 - Metric: food_sales
	RMSE: 281.85
	MAE: 234.79

Store ID: 22260 - Metric: food_sales
	RMSE: 236.24
	MAE: 197.26

Store ID: 23905 - Metric: food_sales
	RMSE: 248.15
	MAE: 203.79

In [ ]:
# Plot actual vs. predicted for 'food_sales' for each store
for store_id in test_stores:
    metric = 'food_sales'
    actual = globals()[f'test_{metric}'][globals()[f'test_{metric}']['store_id'] == store_id]['y']
    predicted = forecasts[(store_id, metric)]['yhat']
    min_length = min(len(actual), len(predicted))
    actual, predicted = actual.iloc[:min_length], predicted.iloc[:min_length]
    plot_actual_vs_predicted(actual, predicted, metric, store_id)
Diesel

In [ ]:
#INCLUDE REGRESSORS
print("Diesel Sales Metrics:")
print_metrics_for_type('diesel')
Diesel Sales Metrics:
Store ID: 22540 - Metric: diesel
	RMSE: 822.41
	MAE: 663.36

Store ID: 24535 - Metric: diesel
	RMSE: 697.04
	MAE: 555.62

Store ID: 22750 - Metric: diesel
	RMSE: 928.61
	MAE: 791.44

Store ID: 22015 - Metric: diesel
	RMSE: 781.81
	MAE: 624.63

Store ID: 22260 - Metric: diesel
	RMSE: 425.60
	MAE: 344.62

Store ID: 23905 - Metric: diesel
	RMSE: 725.64
	MAE: 628.03

In [ ]:
# Plot actual vs. predicted for 'diesel' for each store
for store_id in test_stores:
    metric = 'diesel'
    actual = globals()[f'test_{metric}'][globals()[f'test_{metric}']['store_id'] == store_id]['y']
    predicted = forecasts[(store_id, metric)]['yhat']
    min_length = min(len(actual), len(predicted))
    actual, predicted = actual.iloc[:min_length], predicted.iloc[:min_length]
    plot_actual_vs_predicted(actual, predicted, metric, store_id)
Unleaded

In [ ]:
# WITH REGRESSORS
print("Unleaded Sales Metrics:")
print_metrics_for_type('unleaded')
Unleaded Sales Metrics:
Store ID: 22540 - Metric: unleaded
	RMSE: 1073.06
	MAE: 928.79

Store ID: 24535 - Metric: unleaded
	RMSE: 929.38
	MAE: 761.78

Store ID: 22750 - Metric: unleaded
	RMSE: 1064.55
	MAE: 933.28

Store ID: 22015 - Metric: unleaded
	RMSE: 2253.12
	MAE: 2205.06

Store ID: 22260 - Metric: unleaded
	RMSE: 4459.96
	MAE: 4260.34

Store ID: 23905 - Metric: unleaded
	RMSE: 574.39
	MAE: 460.12

In [ ]:
# Plot actual vs. predicted for 'unleaded' for each store
for store_id in test_stores:
    metric = 'unleaded'
    actual = globals()[f'test_{metric}'][globals()[f'test_{metric}']['store_id'] == store_id]['y']
    predicted = forecasts[(store_id, metric)]['yhat']
    min_length = min(len(actual), len(predicted))
    actual, predicted = actual.iloc[:min_length], predicted.iloc[:min_length]
    plot_actual_vs_predicted(actual, predicted, metric, store_id)
Cross-Validation

Cross-Validation for Prophet shows how the model would forecast daily sales for each metric over 365 days. Performance metrics are outlined below.

In [ ]:
from prophet.diagnostics import cross_validation, performance_metrics
from prophet import Prophet

# Define the cross-validation function for Prophet
def cross_validate_prophet(data, initial, period, horizon, extra_regressors):
    # Initialize the Prophet model with holidays
    model = Prophet(holidays=holidays_df)
    # Add each extra regressor to the model
    for regressor in extra_regressors:
        model.add_regressor(regressor)
    # Fit the model using both the 'ds', 'y', and the extra regressors
    model.fit(data[['ds', 'y'] + extra_regressors])

    # Perform cross-validation
    df_cv = cross_validation(model, initial=initial, period=period, horizon=horizon)

    # Calculate performance metrics
    df_p = performance_metrics(df_cv)
    return df_p

# Define the initial training period, the period between cutoffs, and the forecast horizon
initial = '515 days'  # the first two years of data for training
period = '1 days'   # spacing between cutoff dates
horizon = '365 days'  # forecast horizon

# Create an empty dictionary to store performance metrics for each metric
cv_metrics = {}

# List of metrics
metrics = ['unleaded', 'diesel', 'food_sales', 'inside_sales']

# Loop through each metric to perform cross-validation
for metric in metrics:
    # Get the appropriate DataFrame
    data = globals()[f'prophet_df_{metric}']

    # Perform cross-validation and get performance metrics
    performance = cross_validate_prophet(data, initial, period, horizon, extra_regressors)

    # Store the performance metrics in the dictionary
    cv_metrics[metric] = performance
21:31:45 - cmdstanpy - INFO - Chain [1] start processing
21:31:49 - cmdstanpy - INFO - Chain [1] done processing
21:31:54 - cmdstanpy - INFO - Chain [1] start processing
21:31:56 - cmdstanpy - INFO - Chain [1] done processing
21:32:00 - cmdstanpy - INFO - Chain [1] start processing
21:32:02 - cmdstanpy - INFO - Chain [1] done processing
21:32:07 - cmdstanpy - INFO - Chain [1] start processing
21:32:09 - cmdstanpy - INFO - Chain [1] done processing
21:32:13 - cmdstanpy - INFO - Chain [1] start processing
21:32:15 - cmdstanpy - INFO - Chain [1] done processing
21:32:20 - cmdstanpy - INFO - Chain [1] start processing
21:32:23 - cmdstanpy - INFO - Chain [1] done processing
21:32:28 - cmdstanpy - INFO - Chain [1] start processing
21:32:40 - cmdstanpy - INFO - Chain [1] done processing
21:32:54 - cmdstanpy - INFO - Chain [1] start processing
21:32:59 - cmdstanpy - INFO - Chain [1] done processing
21:33:05 - cmdstanpy - INFO - Chain [1] start processing
21:33:09 - cmdstanpy - INFO - Chain [1] done processing
21:33:17 - cmdstanpy - INFO - Chain [1] start processing
21:33:19 - cmdstanpy - INFO - Chain [1] done processing
21:33:25 - cmdstanpy - INFO - Chain [1] start processing
21:33:27 - cmdstanpy - INFO - Chain [1] done processing
21:33:31 - cmdstanpy - INFO - Chain [1] start processing
21:33:34 - cmdstanpy - INFO - Chain [1] done processing
21:33:39 - cmdstanpy - INFO - Chain [1] start processing
21:33:42 - cmdstanpy - INFO - Chain [1] done processing
21:33:49 - cmdstanpy - INFO - Chain [1] start processing
21:33:53 - cmdstanpy - INFO - Chain [1] done processing
21:33:58 - cmdstanpy - INFO - Chain [1] start processing
21:33:59 - cmdstanpy - INFO - Chain [1] done processing
21:34:04 - cmdstanpy - INFO - Chain [1] start processing
21:34:06 - cmdstanpy - INFO - Chain [1] done processing
21:34:11 - cmdstanpy - INFO - Chain [1] start processing
21:34:14 - cmdstanpy - INFO - Chain [1] done processing
21:34:19 - cmdstanpy - INFO - Chain [1] start processing
21:34:22 - cmdstanpy - INFO - Chain [1] done processing
21:34:26 - cmdstanpy - INFO - Chain [1] start processing
21:34:30 - cmdstanpy - INFO - Chain [1] done processing
21:34:35 - cmdstanpy - INFO - Chain [1] start processing
21:34:38 - cmdstanpy - INFO - Chain [1] done processing
21:34:45 - cmdstanpy - INFO - Chain [1] start processing
21:34:50 - cmdstanpy - INFO - Chain [1] done processing
21:34:57 - cmdstanpy - INFO - Chain [1] start processing
21:35:05 - cmdstanpy - INFO - Chain [1] done processing
21:35:10 - cmdstanpy - INFO - Chain [1] start processing
21:35:12 - cmdstanpy - INFO - Chain [1] done processing
21:35:18 - cmdstanpy - INFO - Chain [1] start processing
21:35:21 - cmdstanpy - INFO - Chain [1] done processing
21:35:26 - cmdstanpy - INFO - Chain [1] start processing
21:35:28 - cmdstanpy - INFO - Chain [1] done processing
21:35:34 - cmdstanpy - INFO - Chain [1] start processing
21:35:36 - cmdstanpy - INFO - Chain [1] done processing
21:35:40 - cmdstanpy - INFO - Chain [1] start processing
21:35:43 - cmdstanpy - INFO - Chain [1] done processing
21:35:49 - cmdstanpy - INFO - Chain [1] start processing
21:35:51 - cmdstanpy - INFO - Chain [1] done processing
21:35:56 - cmdstanpy - INFO - Chain [1] start processing
21:35:59 - cmdstanpy - INFO - Chain [1] done processing
21:36:04 - cmdstanpy - INFO - Chain [1] start processing
21:36:06 - cmdstanpy - INFO - Chain [1] done processing
21:36:10 - cmdstanpy - INFO - Chain [1] start processing
21:36:13 - cmdstanpy - INFO - Chain [1] done processing
21:36:18 - cmdstanpy - INFO - Chain [1] start processing
21:36:20 - cmdstanpy - INFO - Chain [1] done processing
21:36:25 - cmdstanpy - INFO - Chain [1] start processing
21:36:27 - cmdstanpy - INFO - Chain [1] done processing
21:36:37 - cmdstanpy - INFO - Chain [1] start processing
21:36:41 - cmdstanpy - INFO - Chain [1] done processing
21:36:47 - cmdstanpy - INFO - Chain [1] start processing
21:36:52 - cmdstanpy - INFO - Chain [1] done processing
21:36:57 - cmdstanpy - INFO - Chain [1] start processing
21:36:59 - cmdstanpy - INFO - Chain [1] done processing
21:37:06 - cmdstanpy - INFO - Chain [1] start processing
21:37:08 - cmdstanpy - INFO - Chain [1] done processing
21:37:14 - cmdstanpy - INFO - Chain [1] start processing
21:37:16 - cmdstanpy - INFO - Chain [1] done processing
21:37:28 - cmdstanpy - INFO - Chain [1] start processing
21:37:33 - cmdstanpy - INFO - Chain [1] done processing
21:37:38 - cmdstanpy - INFO - Chain [1] start processing
21:37:39 - cmdstanpy - INFO - Chain [1] done processing
21:37:45 - cmdstanpy - INFO - Chain [1] start processing
21:37:47 - cmdstanpy - INFO - Chain [1] done processing
21:37:52 - cmdstanpy - INFO - Chain [1] start processing
21:37:57 - cmdstanpy - INFO - Chain [1] done processing
21:38:01 - cmdstanpy - INFO - Chain [1] start processing
21:38:03 - cmdstanpy - INFO - Chain [1] done processing
21:38:07 - cmdstanpy - INFO - Chain [1] start processing
21:38:10 - cmdstanpy - INFO - Chain [1] done processing
21:38:15 - cmdstanpy - INFO - Chain [1] start processing
21:38:18 - cmdstanpy - INFO - Chain [1] done processing
21:38:23 - cmdstanpy - INFO - Chain [1] start processing
21:38:26 - cmdstanpy - INFO - Chain [1] done processing
21:38:31 - cmdstanpy - INFO - Chain [1] start processing
21:38:33 - cmdstanpy - INFO - Chain [1] done processing
21:38:38 - cmdstanpy - INFO - Chain [1] start processing
21:38:40 - cmdstanpy - INFO - Chain [1] done processing
21:38:44 - cmdstanpy - INFO - Chain [1] start processing
21:38:49 - cmdstanpy - INFO - Chain [1] done processing
21:38:54 - cmdstanpy - INFO - Chain [1] start processing
21:38:58 - cmdstanpy - INFO - Chain [1] done processing
21:39:03 - cmdstanpy - INFO - Chain [1] start processing
21:39:06 - cmdstanpy - INFO - Chain [1] done processing
21:39:12 - cmdstanpy - INFO - Chain [1] start processing
21:39:14 - cmdstanpy - INFO - Chain [1] done processing
21:39:19 - cmdstanpy - INFO - Chain [1] start processing
21:39:21 - cmdstanpy - INFO - Chain [1] done processing
21:39:26 - cmdstanpy - INFO - Chain [1] start processing
21:39:30 - cmdstanpy - INFO - Chain [1] done processing
21:39:37 - cmdstanpy - INFO - Chain [1] start processing
21:39:39 - cmdstanpy - INFO - Chain [1] done processing
21:39:43 - cmdstanpy - INFO - Chain [1] start processing
21:39:46 - cmdstanpy - INFO - Chain [1] done processing
21:39:52 - cmdstanpy - INFO - Chain [1] start processing
21:39:56 - cmdstanpy - INFO - Chain [1] done processing
21:40:08 - cmdstanpy - INFO - Chain [1] start processing
21:40:13 - cmdstanpy - INFO - Chain [1] done processing
21:40:18 - cmdstanpy - INFO - Chain [1] start processing
21:40:21 - cmdstanpy - INFO - Chain [1] done processing
21:40:27 - cmdstanpy - INFO - Chain [1] start processing
21:40:29 - cmdstanpy - INFO - Chain [1] done processing
21:40:35 - cmdstanpy - INFO - Chain [1] start processing
21:40:36 - cmdstanpy - INFO - Chain [1] done processing
21:40:41 - cmdstanpy - INFO - Chain [1] start processing
21:40:46 - cmdstanpy - INFO - Chain [1] done processing
21:40:53 - cmdstanpy - INFO - Chain [1] start processing
21:40:58 - cmdstanpy - INFO - Chain [1] done processing
21:41:05 - cmdstanpy - INFO - Chain [1] start processing
21:41:08 - cmdstanpy - INFO - Chain [1] done processing
21:41:14 - cmdstanpy - INFO - Chain [1] start processing
21:41:17 - cmdstanpy - INFO - Chain [1] done processing
21:41:23 - cmdstanpy - INFO - Chain [1] start processing
21:41:24 - cmdstanpy - INFO - Chain [1] done processing
21:41:30 - cmdstanpy - INFO - Chain [1] start processing
21:41:32 - cmdstanpy - INFO - Chain [1] done processing
21:41:41 - cmdstanpy - INFO - Chain [1] start processing
21:41:43 - cmdstanpy - INFO - Chain [1] done processing
21:42:00 - cmdstanpy - INFO - Chain [1] start processing
21:42:09 - cmdstanpy - INFO - Chain [1] done processing
21:42:14 - cmdstanpy - INFO - Chain [1] start processing
21:42:16 - cmdstanpy - INFO - Chain [1] done processing
21:42:22 - cmdstanpy - INFO - Chain [1] start processing
21:42:24 - cmdstanpy - INFO - Chain [1] done processing
21:42:29 - cmdstanpy - INFO - Chain [1] start processing
21:42:32 - cmdstanpy - INFO - Chain [1] done processing
21:42:37 - cmdstanpy - INFO - Chain [1] start processing
21:42:41 - cmdstanpy - INFO - Chain [1] done processing
21:42:47 - cmdstanpy - INFO - Chain [1] start processing
21:42:49 - cmdstanpy - INFO - Chain [1] done processing
21:42:55 - cmdstanpy - INFO - Chain [1] start processing
21:42:57 - cmdstanpy - INFO - Chain [1] done processing
21:43:03 - cmdstanpy - INFO - Chain [1] start processing
21:43:05 - cmdstanpy - INFO - Chain [1] done processing
21:43:10 - cmdstanpy - INFO - Chain [1] start processing
21:43:14 - cmdstanpy - INFO - Chain [1] done processing
21:43:19 - cmdstanpy - INFO - Chain [1] start processing
21:43:23 - cmdstanpy - INFO - Chain [1] done processing
21:43:28 - cmdstanpy - INFO - Chain [1] start processing
21:43:29 - cmdstanpy - INFO - Chain [1] done processing
21:43:35 - cmdstanpy - INFO - Chain [1] start processing
21:43:38 - cmdstanpy - INFO - Chain [1] done processing
21:43:43 - cmdstanpy - INFO - Chain [1] start processing
21:43:46 - cmdstanpy - INFO - Chain [1] done processing
21:43:51 - cmdstanpy - INFO - Chain [1] start processing
21:43:54 - cmdstanpy - INFO - Chain [1] done processing
21:43:59 - cmdstanpy - INFO - Chain [1] start processing
21:44:00 - cmdstanpy - INFO - Chain [1] done processing
21:44:06 - cmdstanpy - INFO - Chain [1] start processing
21:44:09 - cmdstanpy - INFO - Chain [1] done processing
21:44:14 - cmdstanpy - INFO - Chain [1] start processing
21:44:17 - cmdstanpy - INFO - Chain [1] done processing
21:44:22 - cmdstanpy - INFO - Chain [1] start processing
21:44:25 - cmdstanpy - INFO - Chain [1] done processing
21:44:30 - cmdstanpy - INFO - Chain [1] start processing
21:44:35 - cmdstanpy - INFO - Chain [1] done processing
21:44:47 - cmdstanpy - INFO - Chain [1] start processing
21:44:49 - cmdstanpy - INFO - Chain [1] done processing
21:44:54 - cmdstanpy - INFO - Chain [1] start processing
21:44:56 - cmdstanpy - INFO - Chain [1] done processing
21:45:06 - cmdstanpy - INFO - Chain [1] start processing
21:45:09 - cmdstanpy - INFO - Chain [1] done processing
21:45:15 - cmdstanpy - INFO - Chain [1] start processing
21:45:17 - cmdstanpy - INFO - Chain [1] done processing
21:45:23 - cmdstanpy - INFO - Chain [1] start processing
21:45:25 - cmdstanpy - INFO - Chain [1] done processing
21:45:32 - cmdstanpy - INFO - Chain [1] start processing
21:45:35 - cmdstanpy - INFO - Chain [1] done processing
21:45:40 - cmdstanpy - INFO - Chain [1] start processing
21:45:43 - cmdstanpy - INFO - Chain [1] done processing
21:45:49 - cmdstanpy - INFO - Chain [1] start processing
21:45:52 - cmdstanpy - INFO - Chain [1] done processing
21:45:57 - cmdstanpy - INFO - Chain [1] start processing
21:46:01 - cmdstanpy - INFO - Chain [1] done processing
21:46:07 - cmdstanpy - INFO - Chain [1] start processing
21:46:09 - cmdstanpy - INFO - Chain [1] done processing
21:46:13 - cmdstanpy - INFO - Chain [1] start processing
21:46:16 - cmdstanpy - INFO - Chain [1] done processing
21:46:20 - cmdstanpy - INFO - Chain [1] start processing
21:46:22 - cmdstanpy - INFO - Chain [1] done processing
21:46:26 - cmdstanpy - INFO - Chain [1] start processing
21:46:29 - cmdstanpy - INFO - Chain [1] done processing
21:46:34 - cmdstanpy - INFO - Chain [1] start processing
21:46:37 - cmdstanpy - INFO - Chain [1] done processing
21:46:42 - cmdstanpy - INFO - Chain [1] start processing
21:46:48 - cmdstanpy - INFO - Chain [1] done processing
21:46:52 - cmdstanpy - INFO - Chain [1] start processing
21:46:55 - cmdstanpy - INFO - Chain [1] done processing
21:47:00 - cmdstanpy - INFO - Chain [1] start processing
21:47:03 - cmdstanpy - INFO - Chain [1] done processing
21:47:08 - cmdstanpy - INFO - Chain [1] start processing
21:47:11 - cmdstanpy - INFO - Chain [1] done processing
21:47:17 - cmdstanpy - INFO - Chain [1] start processing
21:47:19 - cmdstanpy - INFO - Chain [1] done processing
21:47:25 - cmdstanpy - INFO - Chain [1] start processing
21:47:26 - cmdstanpy - INFO - Chain [1] done processing
21:47:32 - cmdstanpy - INFO - Chain [1] start processing
21:47:34 - cmdstanpy - INFO - Chain [1] done processing
21:47:41 - cmdstanpy - INFO - Chain [1] start processing
21:47:44 - cmdstanpy - INFO - Chain [1] done processing
21:47:49 - cmdstanpy - INFO - Chain [1] start processing
21:47:52 - cmdstanpy - INFO - Chain [1] done processing
21:47:57 - cmdstanpy - INFO - Chain [1] start processing
21:47:59 - cmdstanpy - INFO - Chain [1] done processing
21:48:04 - cmdstanpy - INFO - Chain [1] start processing
21:48:12 - cmdstanpy - INFO - Chain [1] done processing
21:48:19 - cmdstanpy - INFO - Chain [1] start processing
21:48:24 - cmdstanpy - INFO - Chain [1] done processing
21:48:28 - cmdstanpy - INFO - Chain [1] start processing
21:48:30 - cmdstanpy - INFO - Chain [1] done processing
21:48:35 - cmdstanpy - INFO - Chain [1] start processing
21:48:37 - cmdstanpy - INFO - Chain [1] done processing
21:48:42 - cmdstanpy - INFO - Chain [1] start processing
21:48:45 - cmdstanpy - INFO - Chain [1] done processing
21:48:51 - cmdstanpy - INFO - Chain [1] start processing
21:48:57 - cmdstanpy - INFO - Chain [1] done processing
21:49:06 - cmdstanpy - INFO - Chain [1] start processing
21:49:11 - cmdstanpy - INFO - Chain [1] done processing
21:49:16 - cmdstanpy - INFO - Chain [1] start processing
21:49:19 - cmdstanpy - INFO - Chain [1] done processing
21:49:24 - cmdstanpy - INFO - Chain [1] start processing
21:49:27 - cmdstanpy - INFO - Chain [1] done processing
21:49:32 - cmdstanpy - INFO - Chain [1] start processing
21:49:37 - cmdstanpy - INFO - Chain [1] done processing
21:49:42 - cmdstanpy - INFO - Chain [1] start processing
21:49:46 - cmdstanpy - INFO - Chain [1] done processing
21:49:51 - cmdstanpy - INFO - Chain [1] start processing
21:49:54 - cmdstanpy - INFO - Chain [1] done processing
21:50:00 - cmdstanpy - INFO - Chain [1] start processing
21:50:03 - cmdstanpy - INFO - Chain [1] done processing
21:50:08 - cmdstanpy - INFO - Chain [1] start processing
21:50:12 - cmdstanpy - INFO - Chain [1] done processing
21:50:18 - cmdstanpy - INFO - Chain [1] start processing
21:50:20 - cmdstanpy - INFO - Chain [1] done processing
21:50:25 - cmdstanpy - INFO - Chain [1] start processing
21:50:30 - cmdstanpy - INFO - Chain [1] done processing
21:50:35 - cmdstanpy - INFO - Chain [1] start processing
21:50:39 - cmdstanpy - INFO - Chain [1] done processing
21:50:43 - cmdstanpy - INFO - Chain [1] start processing
21:50:46 - cmdstanpy - INFO - Chain [1] done processing
21:50:51 - cmdstanpy - INFO - Chain [1] start processing
21:50:54 - cmdstanpy - INFO - Chain [1] done processing
21:50:59 - cmdstanpy - INFO - Chain [1] start processing
21:51:03 - cmdstanpy - INFO - Chain [1] done processing
21:51:07 - cmdstanpy - INFO - Chain [1] start processing
21:51:10 - cmdstanpy - INFO - Chain [1] done processing
21:51:14 - cmdstanpy - INFO - Chain [1] start processing
21:51:17 - cmdstanpy - INFO - Chain [1] done processing
21:51:22 - cmdstanpy - INFO - Chain [1] start processing
21:51:25 - cmdstanpy - INFO - Chain [1] done processing
21:51:29 - cmdstanpy - INFO - Chain [1] start processing
21:51:32 - cmdstanpy - INFO - Chain [1] done processing
21:51:37 - cmdstanpy - INFO - Chain [1] start processing
21:51:41 - cmdstanpy - INFO - Chain [1] done processing
21:52:05 - cmdstanpy - INFO - Chain [1] start processing
21:52:13 - cmdstanpy - INFO - Chain [1] done processing
21:52:20 - cmdstanpy - INFO - Chain [1] start processing
21:52:24 - cmdstanpy - INFO - Chain [1] done processing
21:52:29 - cmdstanpy - INFO - Chain [1] start processing
21:52:33 - cmdstanpy - INFO - Chain [1] done processing
21:52:38 - cmdstanpy - INFO - Chain [1] start processing
21:52:41 - cmdstanpy - INFO - Chain [1] done processing
21:52:46 - cmdstanpy - INFO - Chain [1] start processing
21:52:47 - cmdstanpy - INFO - Chain [1] done processing
21:52:52 - cmdstanpy - INFO - Chain [1] start processing
21:52:55 - cmdstanpy - INFO - Chain [1] done processing
21:52:59 - cmdstanpy - INFO - Chain [1] start processing
21:53:02 - cmdstanpy - INFO - Chain [1] done processing
21:53:06 - cmdstanpy - INFO - Chain [1] start processing
21:53:09 - cmdstanpy - INFO - Chain [1] done processing
21:53:14 - cmdstanpy - INFO - Chain [1] start processing
21:53:16 - cmdstanpy - INFO - Chain [1] done processing
21:53:21 - cmdstanpy - INFO - Chain [1] start processing
21:53:24 - cmdstanpy - INFO - Chain [1] done processing
21:53:29 - cmdstanpy - INFO - Chain [1] start processing
21:53:31 - cmdstanpy - INFO - Chain [1] done processing
21:53:36 - cmdstanpy - INFO - Chain [1] start processing
21:53:39 - cmdstanpy - INFO - Chain [1] done processing
21:53:43 - cmdstanpy - INFO - Chain [1] start processing
21:53:46 - cmdstanpy - INFO - Chain [1] done processing
21:53:51 - cmdstanpy - INFO - Chain [1] start processing
21:53:54 - cmdstanpy - INFO - Chain [1] done processing
21:53:59 - cmdstanpy - INFO - Chain [1] start processing
21:54:03 - cmdstanpy - INFO - Chain [1] done processing
21:54:07 - cmdstanpy - INFO - Chain [1] start processing
21:54:10 - cmdstanpy - INFO - Chain [1] done processing
21:54:15 - cmdstanpy - INFO - Chain [1] start processing
21:54:18 - cmdstanpy - INFO - Chain [1] done processing
21:54:23 - cmdstanpy - INFO - Chain [1] start processing
21:54:25 - cmdstanpy - INFO - Chain [1] done processing
21:54:30 - cmdstanpy - INFO - Chain [1] start processing
21:54:32 - cmdstanpy - INFO - Chain [1] done processing
21:54:37 - cmdstanpy - INFO - Chain [1] start processing
21:54:39 - cmdstanpy - INFO - Chain [1] done processing
21:54:44 - cmdstanpy - INFO - Chain [1] start processing
21:54:48 - cmdstanpy - INFO - Chain [1] done processing
21:54:52 - cmdstanpy - INFO - Chain [1] start processing
21:54:55 - cmdstanpy - INFO - Chain [1] done processing
21:55:00 - cmdstanpy - INFO - Chain [1] start processing
21:55:03 - cmdstanpy - INFO - Chain [1] done processing
21:55:08 - cmdstanpy - INFO - Chain [1] start processing
21:55:11 - cmdstanpy - INFO - Chain [1] done processing
21:55:15 - cmdstanpy - INFO - Chain [1] start processing
21:55:17 - cmdstanpy - INFO - Chain [1] done processing
21:55:22 - cmdstanpy - INFO - Chain [1] start processing
21:55:26 - cmdstanpy - INFO - Chain [1] done processing
21:55:31 - cmdstanpy - INFO - Chain [1] start processing
21:55:33 - cmdstanpy - INFO - Chain [1] done processing
21:55:38 - cmdstanpy - INFO - Chain [1] start processing
21:55:40 - cmdstanpy - INFO - Chain [1] done processing
21:55:45 - cmdstanpy - INFO - Chain [1] start processing
21:55:48 - cmdstanpy - INFO - Chain [1] done processing
21:55:53 - cmdstanpy - INFO - Chain [1] start processing
21:55:55 - cmdstanpy - INFO - Chain [1] done processing
21:56:00 - cmdstanpy - INFO - Chain [1] start processing
21:56:03 - cmdstanpy - INFO - Chain [1] done processing
21:56:07 - cmdstanpy - INFO - Chain [1] start processing
21:56:10 - cmdstanpy - INFO - Chain [1] done processing
21:56:15 - cmdstanpy - INFO - Chain [1] start processing
21:56:18 - cmdstanpy - INFO - Chain [1] done processing
21:56:23 - cmdstanpy - INFO - Chain [1] start processing
21:56:26 - cmdstanpy - INFO - Chain [1] done processing
21:56:30 - cmdstanpy - INFO - Chain [1] start processing
21:56:33 - cmdstanpy - INFO - Chain [1] done processing
21:56:38 - cmdstanpy - INFO - Chain [1] start processing
21:56:40 - cmdstanpy - INFO - Chain [1] done processing
21:56:45 - cmdstanpy - INFO - Chain [1] start processing
21:56:48 - cmdstanpy - INFO - Chain [1] done processing
21:56:53 - cmdstanpy - INFO - Chain [1] start processing
21:56:57 - cmdstanpy - INFO - Chain [1] done processing
21:57:01 - cmdstanpy - INFO - Chain [1] start processing
21:57:04 - cmdstanpy - INFO - Chain [1] done processing
21:57:08 - cmdstanpy - INFO - Chain [1] start processing
21:57:11 - cmdstanpy - INFO - Chain [1] done processing
21:57:16 - cmdstanpy - INFO - Chain [1] start processing
21:57:19 - cmdstanpy - INFO - Chain [1] done processing
21:57:24 - cmdstanpy - INFO - Chain [1] start processing
21:57:26 - cmdstanpy - INFO - Chain [1] done processing
21:57:31 - cmdstanpy - INFO - Chain [1] start processing
21:57:34 - cmdstanpy - INFO - Chain [1] done processing
21:57:39 - cmdstanpy - INFO - Chain [1] start processing
21:57:41 - cmdstanpy - INFO - Chain [1] done processing
21:57:46 - cmdstanpy - INFO - Chain [1] start processing
21:57:49 - cmdstanpy - INFO - Chain [1] done processing
21:57:53 - cmdstanpy - INFO - Chain [1] start processing
21:57:57 - cmdstanpy - INFO - Chain [1] done processing
21:58:01 - cmdstanpy - INFO - Chain [1] start processing
21:58:03 - cmdstanpy - INFO - Chain [1] done processing
21:58:08 - cmdstanpy - INFO - Chain [1] start processing
21:58:11 - cmdstanpy - INFO - Chain [1] done processing
21:58:15 - cmdstanpy - INFO - Chain [1] start processing
21:58:18 - cmdstanpy - INFO - Chain [1] done processing
21:58:24 - cmdstanpy - INFO - Chain [1] start processing
21:58:27 - cmdstanpy - INFO - Chain [1] done processing
21:58:32 - cmdstanpy - INFO - Chain [1] start processing
21:58:35 - cmdstanpy - INFO - Chain [1] done processing
21:58:39 - cmdstanpy - INFO - Chain [1] start processing
21:58:42 - cmdstanpy - INFO - Chain [1] done processing
21:58:47 - cmdstanpy - INFO - Chain [1] start processing
21:58:50 - cmdstanpy - INFO - Chain [1] done processing
21:58:55 - cmdstanpy - INFO - Chain [1] start processing
21:58:57 - cmdstanpy - INFO - Chain [1] done processing
21:59:02 - cmdstanpy - INFO - Chain [1] start processing
21:59:05 - cmdstanpy - INFO - Chain [1] done processing
21:59:10 - cmdstanpy - INFO - Chain [1] start processing
21:59:13 - cmdstanpy - INFO - Chain [1] done processing
21:59:18 - cmdstanpy - INFO - Chain [1] start processing
21:59:22 - cmdstanpy - INFO - Chain [1] done processing
21:59:27 - cmdstanpy - INFO - Chain [1] start processing
21:59:30 - cmdstanpy - INFO - Chain [1] done processing
21:59:34 - cmdstanpy - INFO - Chain [1] start processing
21:59:37 - cmdstanpy - INFO - Chain [1] done processing
21:59:41 - cmdstanpy - INFO - Chain [1] start processing
21:59:45 - cmdstanpy - INFO - Chain [1] done processing
21:59:49 - cmdstanpy - INFO - Chain [1] start processing
21:59:53 - cmdstanpy - INFO - Chain [1] done processing
21:59:57 - cmdstanpy - INFO - Chain [1] start processing
22:00:01 - cmdstanpy - INFO - Chain [1] done processing
22:00:06 - cmdstanpy - INFO - Chain [1] start processing
22:00:08 - cmdstanpy - INFO - Chain [1] done processing
22:00:13 - cmdstanpy - INFO - Chain [1] start processing
22:00:16 - cmdstanpy - INFO - Chain [1] done processing
22:00:21 - cmdstanpy - INFO - Chain [1] start processing
22:00:25 - cmdstanpy - INFO - Chain [1] done processing
22:00:30 - cmdstanpy - INFO - Chain [1] start processing
22:00:33 - cmdstanpy - INFO - Chain [1] done processing
22:00:38 - cmdstanpy - INFO - Chain [1] start processing
22:00:40 - cmdstanpy - INFO - Chain [1] done processing
22:00:45 - cmdstanpy - INFO - Chain [1] start processing
22:00:49 - cmdstanpy - INFO - Chain [1] done processing
22:01:03 - cmdstanpy - INFO - Chain [1] start processing
22:01:10 - cmdstanpy - INFO - Chain [1] done processing
22:01:15 - cmdstanpy - INFO - Chain [1] start processing
22:01:18 - cmdstanpy - INFO - Chain [1] done processing
22:01:23 - cmdstanpy - INFO - Chain [1] start processing
22:01:25 - cmdstanpy - INFO - Chain [1] done processing
22:01:30 - cmdstanpy - INFO - Chain [1] start processing
22:01:32 - cmdstanpy - INFO - Chain [1] done processing
22:01:37 - cmdstanpy - INFO - Chain [1] start processing
22:01:39 - cmdstanpy - INFO - Chain [1] done processing
22:01:45 - cmdstanpy - INFO - Chain [1] start processing
22:01:49 - cmdstanpy - INFO - Chain [1] done processing
22:01:54 - cmdstanpy - INFO - Chain [1] start processing
22:01:56 - cmdstanpy - INFO - Chain [1] done processing
22:02:01 - cmdstanpy - INFO - Chain [1] start processing
22:02:04 - cmdstanpy - INFO - Chain [1] done processing
22:02:09 - cmdstanpy - INFO - Chain [1] start processing
22:02:11 - cmdstanpy - INFO - Chain [1] done processing
22:02:16 - cmdstanpy - INFO - Chain [1] start processing
22:02:18 - cmdstanpy - INFO - Chain [1] done processing
22:02:23 - cmdstanpy - INFO - Chain [1] start processing
22:02:25 - cmdstanpy - INFO - Chain [1] done processing
22:02:30 - cmdstanpy - INFO - Chain [1] start processing
22:02:33 - cmdstanpy - INFO - Chain [1] done processing
22:02:49 - cmdstanpy - INFO - Chain [1] start processing
22:02:52 - cmdstanpy - INFO - Chain [1] done processing
22:03:04 - cmdstanpy - INFO - Chain [1] start processing
22:03:15 - cmdstanpy - INFO - Chain [1] done processing
22:03:19 - cmdstanpy - INFO - Chain [1] start processing
22:03:22 - cmdstanpy - INFO - Chain [1] done processing
22:03:28 - cmdstanpy - INFO - Chain [1] start processing
22:03:30 - cmdstanpy - INFO - Chain [1] done processing
22:03:37 - cmdstanpy - INFO - Chain [1] start processing
22:03:41 - cmdstanpy - INFO - Chain [1] done processing
22:03:50 - cmdstanpy - INFO - Chain [1] start processing
22:03:54 - cmdstanpy - INFO - Chain [1] done processing
22:04:01 - cmdstanpy - INFO - Chain [1] start processing
22:04:03 - cmdstanpy - INFO - Chain [1] done processing
22:04:10 - cmdstanpy - INFO - Chain [1] start processing
22:04:12 - cmdstanpy - INFO - Chain [1] done processing
22:04:21 - cmdstanpy - INFO - Chain [1] start processing
22:04:24 - cmdstanpy - INFO - Chain [1] done processing
22:04:30 - cmdstanpy - INFO - Chain [1] start processing
22:04:33 - cmdstanpy - INFO - Chain [1] done processing
22:04:39 - cmdstanpy - INFO - Chain [1] start processing
22:04:42 - cmdstanpy - INFO - Chain [1] done processing
22:04:50 - cmdstanpy - INFO - Chain [1] start processing
22:04:53 - cmdstanpy - INFO - Chain [1] done processing
22:04:59 - cmdstanpy - INFO - Chain [1] start processing
22:05:01 - cmdstanpy - INFO - Chain [1] done processing
22:05:07 - cmdstanpy - INFO - Chain [1] start processing
22:05:11 - cmdstanpy - INFO - Chain [1] done processing
22:05:16 - cmdstanpy - INFO - Chain [1] start processing
22:05:19 - cmdstanpy - INFO - Chain [1] done processing
22:05:25 - cmdstanpy - INFO - Chain [1] start processing
22:05:28 - cmdstanpy - INFO - Chain [1] done processing
22:05:33 - cmdstanpy - INFO - Chain [1] start processing
22:05:36 - cmdstanpy - INFO - Chain [1] done processing
22:05:41 - cmdstanpy - INFO - Chain [1] start processing
22:05:44 - cmdstanpy - INFO - Chain [1] done processing
22:05:49 - cmdstanpy - INFO - Chain [1] start processing
22:05:53 - cmdstanpy - INFO - Chain [1] done processing
22:05:58 - cmdstanpy - INFO - Chain [1] start processing
22:06:01 - cmdstanpy - INFO - Chain [1] done processing
22:06:06 - cmdstanpy - INFO - Chain [1] start processing
22:06:09 - cmdstanpy - INFO - Chain [1] done processing
22:06:14 - cmdstanpy - INFO - Chain [1] start processing
22:06:17 - cmdstanpy - INFO - Chain [1] done processing
22:06:22 - cmdstanpy - INFO - Chain [1] start processing
22:06:25 - cmdstanpy - INFO - Chain [1] done processing
22:06:29 - cmdstanpy - INFO - Chain [1] start processing
22:06:33 - cmdstanpy - INFO - Chain [1] done processing
22:06:37 - cmdstanpy - INFO - Chain [1] start processing
22:06:41 - cmdstanpy - INFO - Chain [1] done processing
22:06:45 - cmdstanpy - INFO - Chain [1] start processing
22:06:46 - cmdstanpy - INFO - Chain [1] done processing
22:06:51 - cmdstanpy - INFO - Chain [1] start processing
22:06:53 - cmdstanpy - INFO - Chain [1] done processing
22:06:58 - cmdstanpy - INFO - Chain [1] start processing
22:07:02 - cmdstanpy - INFO - Chain [1] done processing
22:07:07 - cmdstanpy - INFO - Chain [1] start processing
22:07:11 - cmdstanpy - INFO - Chain [1] done processing
22:07:16 - cmdstanpy - INFO - Chain [1] start processing
22:07:19 - cmdstanpy - INFO - Chain [1] done processing
22:07:24 - cmdstanpy - INFO - Chain [1] start processing
22:07:28 - cmdstanpy - INFO - Chain [1] done processing
22:07:33 - cmdstanpy - INFO - Chain [1] start processing
22:07:36 - cmdstanpy - INFO - Chain [1] done processing
22:07:41 - cmdstanpy - INFO - Chain [1] start processing
22:07:43 - cmdstanpy - INFO - Chain [1] done processing
22:07:48 - cmdstanpy - INFO - Chain [1] start processing
22:07:50 - cmdstanpy - INFO - Chain [1] done processing
22:07:55 - cmdstanpy - INFO - Chain [1] start processing
22:07:58 - cmdstanpy - INFO - Chain [1] done processing
22:08:03 - cmdstanpy - INFO - Chain [1] start processing
22:08:07 - cmdstanpy - INFO - Chain [1] done processing
22:08:12 - cmdstanpy - INFO - Chain [1] start processing
22:08:15 - cmdstanpy - INFO - Chain [1] done processing
22:08:20 - cmdstanpy - INFO - Chain [1] start processing
22:08:24 - cmdstanpy - INFO - Chain [1] done processing
22:08:29 - cmdstanpy - INFO - Chain [1] start processing
22:08:32 - cmdstanpy - INFO - Chain [1] done processing
22:08:37 - cmdstanpy - INFO - Chain [1] start processing
22:08:40 - cmdstanpy - INFO - Chain [1] done processing
22:08:45 - cmdstanpy - INFO - Chain [1] start processing
22:08:48 - cmdstanpy - INFO - Chain [1] done processing
22:08:54 - cmdstanpy - INFO - Chain [1] start processing
22:08:56 - cmdstanpy - INFO - Chain [1] done processing
22:09:01 - cmdstanpy - INFO - Chain [1] start processing
22:09:04 - cmdstanpy - INFO - Chain [1] done processing
22:09:09 - cmdstanpy - INFO - Chain [1] start processing
22:09:12 - cmdstanpy - INFO - Chain [1] done processing
22:09:17 - cmdstanpy - INFO - Chain [1] start processing
22:09:19 - cmdstanpy - INFO - Chain [1] done processing
22:09:24 - cmdstanpy - INFO - Chain [1] start processing
22:09:26 - cmdstanpy - INFO - Chain [1] done processing
22:09:31 - cmdstanpy - INFO - Chain [1] start processing
22:09:34 - cmdstanpy - INFO - Chain [1] done processing
22:09:39 - cmdstanpy - INFO - Chain [1] start processing
22:09:42 - cmdstanpy - INFO - Chain [1] done processing
22:09:48 - cmdstanpy - INFO - Chain [1] start processing
22:09:51 - cmdstanpy - INFO - Chain [1] done processing
22:09:56 - cmdstanpy - INFO - Chain [1] start processing
22:10:00 - cmdstanpy - INFO - Chain [1] done processing
22:10:05 - cmdstanpy - INFO - Chain [1] start processing
22:10:09 - cmdstanpy - INFO - Chain [1] done processing
22:10:13 - cmdstanpy - INFO - Chain [1] start processing
22:10:17 - cmdstanpy - INFO - Chain [1] done processing
22:10:22 - cmdstanpy - INFO - Chain [1] start processing
22:10:26 - cmdstanpy - INFO - Chain [1] done processing
22:10:32 - cmdstanpy - INFO - Chain [1] start processing
22:10:35 - cmdstanpy - INFO - Chain [1] done processing
22:10:41 - cmdstanpy - INFO - Chain [1] start processing
22:10:45 - cmdstanpy - INFO - Chain [1] done processing
22:10:52 - cmdstanpy - INFO - Chain [1] start processing
22:10:57 - cmdstanpy - INFO - Chain [1] done processing
Inside Sales

In [ ]:
# Print the performance metrics for inside_sales
print("Performance metrics for inside_sales:")
inside_sales_performance = cv_metrics['inside_sales']
print(inside_sales_performance)
print("\n")
Performance metrics for inside_sales:
     horizon           mse         rmse         mae      mape     mdape  \
0    24 days  1.170727e+06  1082.001361  878.936103  0.339370  0.255625   
1    25 days  1.173070e+06  1083.083357  880.046573  0.339617  0.255872   
2    26 days  1.175488e+06  1084.199215  881.168423  0.339933  0.256821   
3    27 days  1.177467e+06  1085.111706  882.025094  0.340148  0.257294   
4    28 days  1.177706e+06  1085.221785  882.220032  0.340179  0.257397   
..       ...           ...          ...         ...       ...       ...   
337 361 days  8.164992e+05   903.603460  715.290894  0.217026  0.195027   
338 362 days  8.165917e+05   903.654618  715.836522  0.217210  0.195165   
339 363 days  8.161803e+05   903.426951  716.028016  0.217281  0.195186   
340 364 days  8.155686e+05   903.088359  716.000455  0.217290  0.195183   
341 365 days  8.142334e+05   902.348851  715.656627  0.217196  0.195125   

        smape  coverage  
0    0.295516  0.608153  
1    0.295831  0.607708  
2    0.296230  0.607640  
3    0.296532  0.607661  
4    0.296669  0.607671  
..        ...       ...  
337  0.235980  0.739047  
338  0.236052  0.738581  
339  0.236013  0.738085  
340  0.235913  0.737965  
341  0.235715  0.738029  

[342 rows x 8 columns]


Food Service

In [ ]:
# Print the performance metrics for food_sales
print("Performance metrics for food_sales:")
food_sales_performance = cv_metrics['food_sales']
print(food_sales_performance)
print("\n")
Performance metrics for food_sales:
     horizon            mse        rmse         mae      mape     mdape  \
0    24 days  131959.371565  363.262125  298.648738  0.464103  0.342834   
1    25 days  131761.000166  362.988981  298.437301  0.463345  0.342103   
2    26 days  131603.855826  362.772457  298.191174  0.462582  0.342365   
3    27 days  131408.792173  362.503506  297.983524  0.462120  0.342002   
4    28 days  130828.602072  361.702367  297.256569  0.460885  0.340675   
..       ...            ...         ...         ...       ...       ...   
337 361 days   77446.958449  278.292936  220.278371  0.268840  0.208577   
338 362 days   77307.838954  278.042873  220.231928  0.268666  0.208475   
339 363 days   77016.627665  277.518698  219.916810  0.268172  0.208180   
340 364 days   76812.117616  277.149991  219.690254  0.267856  0.207847   
341 365 days   76613.596959  276.791613  219.511592  0.267542  0.207728   

        smape  coverage  
0    0.384778  0.535281  
1    0.384022  0.534373  
2    0.383398  0.534283  
3    0.382891  0.533914  
4    0.381709  0.534570  
..        ...       ...  
337  0.255744  0.738830  
338  0.255603  0.739098  
339  0.255182  0.740011  
340  0.254865  0.740711  
341  0.254592  0.741070  

[342 rows x 8 columns]


Diesel

In [ ]:
# Print the performance metrics for diesel
print("Performance metrics for diesel:")
diesel_performance = cv_metrics['diesel']
print(diesel_performance)
print("\n")
Performance metrics for diesel:
     horizon           mse         rmse          mae      mape     mdape  \
0    24 days  2.658320e+06  1630.435602  1321.812782  3.049102  0.886403   
1    25 days  2.662608e+06  1631.749924  1322.987987  3.048038  0.883811   
2    26 days  2.663953e+06  1632.161992  1323.378950  3.042042  0.885262   
3    27 days  2.666592e+06  1632.970337  1324.080879  3.039935  0.884577   
4    28 days  2.666830e+06  1633.043208  1323.723729  3.038253  0.883595   
..       ...           ...          ...          ...       ...       ...   
337 361 days  5.121323e+06  2263.034053  1729.436763  1.866527  0.922977   
338 362 days  5.138152e+06  2266.749226  1732.485633  1.858379  0.923434   
339 363 days  5.151884e+06  2269.776194  1735.086095  1.850251  0.922131   
340 364 days  5.168467e+06  2273.426304  1738.281644  1.843828  0.921617   
341 365 days  5.186600e+06  2277.410746  1741.751682  1.837819  0.921548   

        smape  coverage  
0    1.021624  0.413324  
1    1.021974  0.412645  
2    1.022382  0.411769  
3    1.022636  0.411205  
4    1.022000  0.411194  
..        ...       ...  
337  1.294363  0.390635  
338  1.294618  0.390134  
339  1.294717  0.389942  
340  1.295014  0.389286  
341  1.295309  0.388853  

[342 rows x 8 columns]


Unleaded

In [ ]:
# Print the performance metrics for unleaded
print("Performance metrics for unleaded:")
unleaded_performance = cv_metrics['unleaded']
print(unleaded_performance)
print("\n")
Performance metrics for unleaded:
     horizon           mse         rmse          mae      mape     mdape  \
0    24 days  2.099217e+06  1448.867476  1172.241065  0.610317  0.393563   
1    25 days  2.098971e+06  1448.782488  1172.225652  0.609694  0.393707   
2    26 days  2.100044e+06  1449.153008  1171.616998  0.609360  0.392695   
3    27 days  2.097993e+06  1448.445198  1171.020329  0.609059  0.392710   
4    28 days  2.095545e+06  1447.599753  1170.759237  0.608744  0.393372   
..       ...           ...          ...          ...       ...       ...   
337 361 days  1.082385e+06  1040.377142   846.050276  0.486677  0.289081   
338 362 days  1.083878e+06  1041.094819   846.717428  0.486997  0.289147   
339 363 days  1.085185e+06  1041.722249   847.161267  0.487329  0.288915   
340 364 days  1.086918e+06  1042.553641   847.912550  0.487778  0.288915   
341 365 days  1.088225e+06  1043.180026   848.720746  0.488117  0.289044   

        smape  coverage  
0    0.459843  0.520038  
1    0.459824  0.520249  
2    0.459530  0.521295  
3    0.459400  0.521330  
4    0.459511  0.521162  
..        ...       ...  
337  0.354369  0.692158  
338  0.354460  0.691553  
339  0.354487  0.691334  
340  0.354642  0.691192  
341  0.354841  0.690646  

[342 rows x 8 columns]


XGBoost

XGBoost, which stands for Extreme Gradient Boosting, is a scalable, distributed gradient-boosted decision tree (GBDT) machine learning library. It provides parallel tree boosting and is the leading machine learning library for regression, classification, and ranking problems.

The model runs quickly and efficiently for this initial round of exploration and fitting. As we build upon and tune the model, we may need to reevaluate these statistics. Like we mentioned earlier in the analysis, we will primarily use RMSE to evaluate model performance.

In [ ]:
import xgboost as xgb
from xgboost import plot_importance, plot_tree
plt.style.use('fivethirtyeight')

model_df2['site_id_msba'].nunique()

np.random.seed(1234)

unique_sites = model_df2['site_id_msba'].unique()
np.random.shuffle(unique_sites)
random_unique_sites = unique_sites[:6]
test_sites = random_unique_sites.tolist()

print(test_sites)
#Splitting the dataset into train and test sets based on site id

stores_for_testing = test_sites
stores_for_training = [x for x in unique_sites if x not in test_sites]

train_data = model_df2[model_df2['site_id_msba'].isin(stores_for_training)]
test_data = model_df2[model_df2['site_id_msba'].isin(stores_for_testing)]
# Get unique 'site_id_msba' values from test_data
unique_site_ids = test_data['site_id_msba'].unique()

# Create a dictionary to store the separate DataFrames
test_data_dict = {}

# Iterate through unique site IDs and create separate DataFrames
for idx, site_id in enumerate(unique_site_ids, start=1):
    # Filter the test_data for the current site_id
    test_data_site = test_data[test_data['site_id_msba'] == site_id]

    # Store the filtered DataFrame in the dictionary with a numerical key
    test_data_dict[idx] = test_data_site

# Access the separate DataFrames as test_data_1, test_data_2, test_data_3, etc.
# For example, to access test_data for 'site_id_msba' 1:
test_data_1 = test_data_dict[1]
test_data_2 = test_data_dict[2]
test_data_3 = test_data_dict[3]
test_data_4 = test_data_dict[4]
test_data_5 = test_data_dict[5]
test_data_6 = test_data_dict[6]
[22540, 24535, 22750, 22015, 22260, 23905]
In [ ]:
def create_features(df, label=None):
    """
    Creates time series features from datetime index
    """
    df['date'] = df.index
    df['dayofweek'] = df['date'].dt.dayofweek
    df['quarter'] = df['date'].dt.quarter
    df['month'] = df['date'].dt.month
    df['year'] = df['date'].dt.year
    df['dayofyear'] = df['date'].dt.dayofyear
    df['dayofmonth'] = df['date'].dt.day
    df['weekofyear'] = df['date'].dt.weekofyear

    X = df[['dayofweek','quarter','month','year',
           'dayofyear','dayofmonth','weekofyear']]
    if label:
        y = df[label]
        return X, y
    return X
In [ ]:
# function for mean absolute percentage error
def mean_absolute_percentage_error(y_true, y_pred):
    """Calculates MAPE given y_true and y_pred"""
    y_true, y_pred = np.array(y_true), np.array(y_pred)
    return np.mean(np.abs((y_true - y_pred) / y_true)) * 100
In [ ]:
# fetching datasets
train_xgb = train_data.copy()
test_xgb = test_data.copy()
Inside Sales

Benchmark
(MAE): 707.2735125491541 (RMSE): 967.2567077320317

In [ ]:
# fetching key variable
test = test_xgb['daily_yoy_ndt.total_inside_sales']
train = train_xgb['daily_yoy_ndt.total_inside_sales']

train=train.to_frame()
test=test.to_frame()
In [ ]:
# adding additional features
X_train, y_train = create_features(train, label='daily_yoy_ndt.total_inside_sales')
X_test, y_test = create_features(test, label='daily_yoy_ndt.total_inside_sales')
In [ ]:
# train + fit model
reg = xgb.XGBRegressor(n_estimators=1000, enable_categorical=True)
reg.fit(X_train, y_train,
        eval_set=[(X_train, y_train), (X_test, y_test)],
        early_stopping_rounds=50,
       verbose=False) # Change verbose to True if you want to see it train

# Generate predictions
y_pred = reg.predict(X_test)

# Store predictions in the test DataFrame
test['Prediction'] = y_pred
[23:58:05] WARNING: /opt/concourse/worker/volumes/live/7a2b9f41-3287-451b-6691-43e9a6c0910f/volume/xgboost-split_1619728204606/work/src/learner.cc:541: 
Parameters: { enable_categorical } might not be used.

  This may not be accurate due to some parameters are only used in language bindings but
  passed down to XGBoost core.  Or some parameters are not used but slip through this
  verification. Please open an issue if you find above cases.


In [ ]:
# plots were originally designed to split by date and not store, so they were omitted
# performance markings are available in aggregate, rather than by store
MSE = mean_squared_error(y_true=test['daily_yoy_ndt.total_inside_sales'],
                   y_pred=test['Prediction'])
print("Mean Squared Error:\n")
print(MSE)
RMSE = math.sqrt(MSE)
print("Root Mean Square Error:\n")
print(RMSE)
MA = mean_absolute_error(y_true=test['daily_yoy_ndt.total_inside_sales'],
                   y_pred=test['Prediction'])
print("Mean Absolute Error:\n")
print(MA)
MAPE = mean_absolute_percentage_error(y_true=test['daily_yoy_ndt.total_inside_sales'],
                   y_pred=test['Prediction'])
print("Mean Absolute Percentage Error:\n")
print(MAPE)
Mean Squared Error:

992404.737880822
Root Mean Square Error:

996.1951304241665
Mean Absolute Error:

741.8882113097143
Mean Absolute Percentage Error:

23.882223500734405
Food Service

Benchmark (MAE): 236.37052076466694 (RMSE): 298.75333424739136

In [ ]:
# fetching key variable
test = test_xgb['daily_yoy_ndt.total_food_service']
train = train_xgb['daily_yoy_ndt.total_food_service']

train=train.to_frame()
test=test.to_frame()
In [ ]:
# adding additional features
X_train, y_train = create_features(train, label='daily_yoy_ndt.total_food_service')
X_test, y_test = create_features(test, label='daily_yoy_ndt.total_food_service')
In [ ]:
# train + fit model
reg = xgb.XGBRegressor(n_estimators=1000)
reg.fit(X_train, y_train,
        eval_set=[(X_train, y_train), (X_test, y_test)],
        early_stopping_rounds=50,
       verbose=False) # Change verbose to True if you want to see it train
# Generate predictions
y_pred = reg.predict(X_test)

# Store predictions in the test DataFrame
test['Prediction'] = y_pred
In [ ]:
# plots were originally designed to split by date and not store, so they were omitted
# performance markings are available in aggregate, rather than by store
MSE = mean_squared_error(y_true=test['daily_yoy_ndt.total_food_service'],
                   y_pred=test['Prediction'])
print("Mean Squared Error:\n")
print(MSE)
RMSE = math.sqrt(MSE)
print("Root Mean Square Error:\n")
print(RMSE)
MA = mean_absolute_error(y_true=test['daily_yoy_ndt.total_food_service'],
                   y_pred=test['Prediction'])
print("Mean Absolute Error:\n")
print(MA)
MAPE = mean_absolute_percentage_error(y_true=test['daily_yoy_ndt.total_food_service'],
                   y_pred=test['Prediction'])
print("Mean Absolute Percentage Error:\n")
print(MAPE)
Mean Squared Error:

82358.65367051333
Root Mean Square Error:

286.98197446967527
Mean Absolute Error:

223.0049279651746
Mean Absolute Percentage Error:

31.352681455298814
Diesel

Benchmark (MAE): 889.6733050759848 (RMSE): 1003.2789422445452

In [ ]:
# fetching key variable
test = test_xgb['diesel_y']
train = train_xgb['diesel_y']

train=train.to_frame()
test=test.to_frame()
In [ ]:
# adding additional features
X_train, y_train = create_features(train, label='diesel_y')
X_test, y_test = create_features(test, label='diesel_y')
In [ ]:
# train + fit model
reg = xgb.XGBRegressor(n_estimators=1000)
reg.fit(X_train, y_train,
        eval_set=[(X_train, y_train), (X_test, y_test)],
        early_stopping_rounds=50,
       verbose=False) # Change verbose to True if you want to see it train

# Generate predictions
y_pred = reg.predict(X_test)

# Store predictions in the test DataFrame
test['Prediction'] = y_pred
In [ ]:
# plots were originally designed to split by date and not store, so they were omitted
# performance markings are available in aggregate, rather than by store
MSE = mean_squared_error(y_true=test['diesel_y'],
                   y_pred=test['Prediction'])
print("Mean Squared Error:\n")
print(MSE)
RMSE = math.sqrt(MSE)
print("Root Mean Square Error:\n")
print(RMSE)
MA = mean_absolute_error(y_true=test['diesel_y'],
                   y_pred=test['Prediction'])
print("Mean Absolute Error:\n")
print(MA)
MAPE = mean_absolute_percentage_error(y_true=test['diesel_y'],
                   y_pred=test['Prediction'])
print("Mean Absolute Percentage Error:\n")
print(MAPE)
Mean Squared Error:

534733.0375379795
Root Mean Square Error:

731.2544273629935
Mean Absolute Error:

610.2971993583859
Mean Absolute Percentage Error:

110.47597076575737
Unleaded

Benchmark (MAE): 906.8842300356473 (RMSE): 1345.069038082699

In [ ]:
# fetching key variable
test = test_xgb['unleaded']
train = train_xgb['unleaded']

train=train.to_frame()
test=test.to_frame()
In [ ]:
# adding additional features
X_train, y_train = create_features(train, label='unleaded')
X_test, y_test = create_features(test, label='unleaded')
In [ ]:
# train + fit model
reg = xgb.XGBRegressor(n_estimators=1000)
reg.fit(X_train, y_train,
        eval_set=[(X_train, y_train), (X_test, y_test)],
        early_stopping_rounds=50,
       verbose=False) # Change verbose to True if you want to see it train

# Generate predictions
y_pred = reg.predict(X_test)

# Store predictions in the test DataFrame
test['Prediction'] = y_pred
In [ ]:
# plots were originally designed to split by date and not store, so they were omitted
# performance markings are available in aggregate, rather than by store
MSE = mean_squared_error(y_true=test['unleaded'],
                   y_pred=test['Prediction'])
print("Mean Squared Error:\n")
print(MSE)
RMSE = math.sqrt(MSE)
print("Root Mean Square Error:\n")
print(RMSE)
MA = mean_absolute_error(y_true=test['unleaded'],
                   y_pred=test['Prediction'])
print("Mean Absolute Error:\n")
print(MA)
MAPE = mean_absolute_percentage_error(y_true=test['unleaded'],
                   y_pred=test['Prediction'])
print("Mean Absolute Percentage Error:\n")
print(MAPE)
Mean Squared Error:

1969660.768269294
Root Mean Square Error:

1403.4460332585982
Mean Absolute Error:

987.473078505219
Mean Absolute Percentage Error:

36.70616356413296

Results

The average RMSE for each sales metric for the models are as follows:

ETS

Inside Sales: 966.19

Food Service: 301.34

Diesel: 794.32

Unleaded: 1302.74

ARIMA

Inside Sales: 903.78

Food Service: 308.01

Diesel: 1006.06

Unleaded: 1100.31

Prophet

Inside Sales: 834.43

Food Service: 287.61

Diesel: 730.11

Unleaded: 1726.23

XGBoost

Inside Sales: 974.08

Food Service: 279.92

Diesel: 893.82

Unleaded: 1403.42

All models performed very well. However, Prophet produces the lowest RMSE scores for all sales metrics (with the exception of unleaded). As of this assignment submission, we will move forward with Prophet.

Before we present to Maverik, we will continue to make improvements to our models to see if any perform better than Prophet.

  1. ETS could incorporate rolling window and feature selection.
  1. ARIMA will have hyperparameters tuned, as well as adding seasonal ordering to identify trends.
  1. Prophet hyperparameters will be tuned.
  1. XGBoost could have more robust feature selection and creation. Could look into testing several test stores individually instead of aggregate.

Contributions

Bhoomika John Pedely

  • Collaborated with team to make decisions regarding the modeling process
  • Worked with the team to preprocess the data
  • Trained and tested the ETS model
  • Contributed to the writing and organization of the document

Roman Brock

  • Worked with the team to algin modeling process / datasets
  • Trained and tested XGBoost model
  • Helped the team assemble the final document
  • Tested splitting the data by date in addition to by store

Pablo Zarate

  • Worked with team to align modeling processes
  • Trained and tested Prophet
  • Contributed to the writing and organization of the final document

Biva Sherchan

  • Worked with the team to do our individual modeling and came prepared in team meetings to discuss the success and failures during the modeling process
  • Trained and tested ARIMA model
  • Contributed to put together the notebook